HEIF Image Conversion and Layout Generation
Recently, my wife tasked me with printing hundreds of photos from mixed sources (iPhone, camera, WhatsApp) for her scrapbooking activities, which presented two primary technical challenges:
- Format incompatibility: HEIF (
.heic) files from iOS Live Photos were not supported by the printing layout software I had installed - Manual layout inefficiency: Arranging photos in print layouts was manual and time-consuming
Rather than relying on third-party online tools or manual processes, I developed two Python utilities to automate the entire workflow:
- HEIC Converter: Batch converts HEIF images to standard formats (JPEG/PNG/WEBP)
- Layout Generator: Arranges images in grid layouts optimized for printing
HEIC to JPEG Conversion⏚
GitHub: heic_converter
Key Dependencies:
pyheif: HEIF/AVIF decoder support via libheifPillow (PIL): Image processing
Description:
The converter uses pyheif to decode HEIC files into raw image data, then leverages Pillow to perform the format conversion. The tool supports multiple output formats and includes comprehensive error handling for corrupted files.
PDF Layout Generation⏚
GitHub: layout_gen
Key Dependencies:
Pillow: Image processingReportLab: PDF generation and document layout
Description: The layout generator creates PDF documents with configurable grid layouts, automatically rotating and cropping images to optimize for printing.
Current Limitations & Future Enhancements:
-
Cropping Algorithm: Currently uses edge-based cropping without content-aware centering, meaning subjects near image edges may be cropped out.
-
Uniform Sizing Constraint: All images in a layout use identical dimensions, requiring separate invocations when dealing with mixed aspect ratios.