https://github.com/johnanon9771/mockup-generator
MockupGenerator is a Ruby tool that generates realistic mockups from templates, masks and graphic arts using the RMagick library.
https://github.com/johnanon9771/mockup-generator
rmagick ruby
Last synced: 11 months ago
JSON representation
MockupGenerator is a Ruby tool that generates realistic mockups from templates, masks and graphic arts using the RMagick library.
- Host: GitHub
- URL: https://github.com/johnanon9771/mockup-generator
- Owner: JohnAnon9771
- Created: 2024-09-11T01:33:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-15T15:30:58.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T14:13:47.143Z (about 1 year ago)
- Topics: rmagick, ruby
- Language: Ruby
- Homepage:
- Size: 7.09 MB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MockupGenerator
MockupGenerator is a Ruby tool that generates realistic mockups from templates, masks, and artworks using the RMagick library.
## Table of Contents
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Results](#results)
- [Explanation of Steps](#explanation-of-steps)
## Features
- Generates adjustment, displacement, and lighting maps to create realistic mockups.
- Supports customization of templates and artworks.
- Uses algorithms to calculate average brightness and adjust the mockup accordingly.
## Requirements
- Ruby (version 2.5 or higher)
- `rmagick` gem
- ImageMagick installed on the system
## Installation
1. **Install ImageMagick** on your system:
- **macOS**:
```bash
brew install imagemagick
```
- **Ubuntu/Debian**:
```bash
sudo apt-get install imagemagick
```
2. **Install the RMagick gem**:
```bash
gem install rmagick
```
3. **Clone the repository**:
```bash
git clone https://github.com/your_username/MockupGenerator.git
```
4. **Navigate to the project directory**:
```bash
cd MockupGenerator
```
## Usage
```ruby
require 'rmagick'
require './mockup_generator'
# Paths to the files
template = "/path/to/template.jpg"
mask = "/path/to/mask.png"
artwork = "/path/to/artwork.png"
# Initialize the mockup generator
generator = MockupGenerator.new(template, mask, artwork)
# Generate the mockup
generator.generate
```
The generated files will be saved in the current directory:
- `adjustment_map.jpg`
- `displacement_map.png`
- `lighting_map.png`
- `mockup.png`
## Examples
### Template
Base image where the artwork will be applied.

### Mask
Defines the area where the artwork will be positioned on the template.

### Artwork
The image that will be inserted into the mockup.

## Results
After running the script, you will get a mockup with the artwork applied realistically.

## Explanation of Steps
1. **Generation of Adjustment Map**: Creates a map that adjusts the brightness and contrast of the artwork to match the template.
2. **Generation of Displacement Map**: Applies a displacement effect to simulate the texture and contours of the template on the artwork.
3. **Generation of Lighting Map**: Adjusts the lighting of the artwork to correspond with the lighting of the template.
4. **Generation of the Final Mockup**: Combines all the maps and applies the artwork to the template, producing the final mockup.