Contact Sheet Generator is a Python script that generates a contact sheet from a directory of images. It uses the PIL
library to process images and multiprocessing
to generate thumbnails in parallel. The contact sheet is created by arranging the thumbnails in a grid pattern.
Also, it generates grid pattern without cropping the images. It supports both vertical and horizontal. All images automatically fit into the final grid pattern. You can use this feature with --no-crop
argument in command line.
- Python 3.x
PIL
library (pillow
package)multiprocessing
moduletqdm
libraryrectpack
librarywand
library
- Clone the repository:
git clone https://github.com/cobanov/contact-sheet-generator.git
- Install the required dependencies.
pip install -r requirements.txt
-
Place your images in a directory.
-
Open the command prompt or terminal and navigate to the project directory.
-
Run the script with the following command:
python contact_sheet.py /path/to/images output_contact_sheet.jpg
- Also, you can specify options with additional arguments (--img-size , --heic_to, --shuffle --no-crop)
important : if you want to use heic_to
feature, please refer ImageMagick download page and install it for desired platform.
python contract_sheet.py /path/to/images --shuffle --heic_to jpeg --img-size 500 --no-crop result.jpg
Replace /path/to/images with the directory path containing the images you want to generate a contact sheet from, and output_contact_sheet.jpg with the desired output file path for the contact sheet.
-
The script will start generating the contact sheet and display progress bars using the tqdm library.
-
Once the process completes, the contact sheet will be saved to the specified output file path.
Name | Type | Description |
---|---|---|
--image_dir | str | Path of image directory |
--file_list(optional) | str | Path to the file list (filelist.txt) if available |
--img-size(optional) | int | Adjust image size to process |
--no-crop(optional) | bool | Create without cropping images, support v&h pictures |
--heic_to | str | convert .HEIC images to desired( .jpg or .png) |
--shuffle | bool | Shuffle thumbnail images for get different output |
output_file | str | Output file name |
The thumbnail_size variable in the script can be adjusted to control the size of the thumbnails in the contact sheet.
The script uses the center square crop technique to crop the images before generating thumbnails. This ensures that each thumbnail is a centered square.
The script utilizes multiprocessing to generate thumbnails in parallel, which can significantly speed up the process for a large number of images.
Progress tracking is added using the tqdm library, which displays progress bars while generating thumbnails and processing the images.
The temporary thumbnail directory used during the process will be cleaned up automatically after the contact sheet is generated.
Feel free to modify and customize the script according to your specific requirements!
This project is licensed under the MIT License