Image compositor based on Node.js + Moleculer + Sharp
This software combines multiple image layers (like Photoshop layers) to create unique compositions. Each layer is stacked on top of another, creating final images with transparency.
Here are some examples of images generated by the system:
Images are organized in numbered folders (assets/0/, assets/1/, assets/2/, etc.). Each folder represents a layer:
assets/0/- Background (base image)assets/1/- First layer on topassets/2/- Second layer on top- And so on...
Important: All images must have transparency (PNG) for the overlay to work correctly. The software combines any image with transparency, enabling endless creation possibilities.
The readAssets scans all folders and creates all possible combinations in the database. Each combination is unique and non-repeating.
Numbers are automatically generated from PNG fonts (in the fonts/ folder). Each digit (0-9) is a separate image, and the software automatically composes the numbers.
You can use your own fonts by placing PNG images of 0-9 in the fonts/ folder.
- Current images: 10000 x 10000 px (10K)
- High resolution: The software can handle large resolution images
- Note: With lower resolutions, processing time is significantly faster
Images don't need to be square, but it is recommended that all layers have the same resolution. Otherwise, the final image may have unexpected behavior (images out of position, cropped, etc.).
The rescale action scales images to a percentage of their original size. It works with both:
- Folder structure: Will maintain the folder hierarchy (e.g.,
assets/0/→output/0/) - Single folder: Will process all PNG files directly
Parameters:
sourceDir: Source folder pathoutputDir: Destination folder pathpercentage: Scale percentage (e.g., 50 = 50% of original, 200 = double size)
Examples:
percentage: 100→ keeps original sizepercentage: 50→ reduces to halfpercentage: 200→ doubles the size
Use case: If your assets are 10K (10000x10000), processing is slow. Scale to 40% for much faster generation, then use the smaller images for testing or quick previews.
npm installnpm run dev# Populate database with combinations
mol $ call imagery.readAssets
# Create images without numbers
mol $ call imagery.createImage '{"count": 1}'
# Create images with numbers
mol $ call imagery.createImageWithNumbers '{"count": 1}'
# Rescale images (e.g., 50% of original size)
mol $ call imagery.rescale '{"sourceDir": "./assets/", "outputDir": "./dist/output-scale/", "percentage": 50}'image-composition-engine/
├── assets/ # Original images (layers)
│ ├── 0/ # Backgrounds
│ ├── 1/ # Letters
│ ├── 2/ # Shapes
│ ├── 3/ # Effects
│ ├── 4/ # Magic
│ └── 5/ # Glow
├── fonts/ # Numbers (0-9) - you can replace with your own fonts
├── demo-material/ # Generated image examples
├── dist/
│ ├── data/ # SQLite database
│ ├── numbers/ # Generated numbers
│ └── output/ # Final images
To create your own compositions:
- Place your PNG images with transparency in folders
assets/0/,assets/1/, etc. - Run
readAssetsto generate combinations - Use
createImageWithNumbersto generate your images
node test/engine.test.js

