collage.sh is a simple command-line tool to generate a uniform photo collage from all images in the current directory.
It uses ImageMagick under the hood (montage command).
- Works with JPG/JPEG/PNG images (case-insensitive).
- Automatically detects the number of images and creates a near-square grid.
- Resizes all images to uniform cells while preserving the full image (adds padding as needed).
- Adjustable thumbnail size and output filename via CLI arguments.
- Default background color is white (can be changed in the script).
- ImageMagick must be installed.
Install on:
- macOS:
brew install imagemagick
-
Ubuntu/Debian:
sudo apt-get install imagemagick
-
Save the script as
collage.sh -
Make it executable:
chmod +x collage.sh
-
Run it in a folder containing your images:
./collage.sh
./collage.sh [SIZE] [OUTPUT]SIZEβ (optional) cell size for each image, e.g.300x300(default:300x300).OUTPUTβ (optional) output file name (default:collage.jpg).
-
Default:
./collage.sh
β Creates
collage.jpgwith 300Γ300 image cells. -
Custom size:
./collage.sh 400x400
β Creates
collage.jpgwith 400Γ400 cells. -
Custom size + output filename:
./collage.sh 400x400 mycollage.png
β Creates
mycollage.pngwith 400Γ400 cells.
- The grid size is automatically chosen based on the number of images.
- Images are resized to fit inside the chosen
SIZEwhile keeping their full content visible. - Empty space is padded (default: white). Change
-background whitein the script if you prefer black or transparent.
If you have 9 images in a directory and run:
./collage.sh 300x300 collage.jpgYouβll get a neat 3Γ3 collage, with each image scaled to fit a 300Γ300 cell.
MIT β feel free to use and modify.