Recently my wife tasked me with printing hundreds of photos from mixed sources (iPhone, camera, WhatsApp) for her scrapbooking activities, which raised two primary technical challenges:

  1. Format incompatibility: HEIF (.heic) files from iOS Live Photos not being supported with the printing layout software that I ad installed
  2. Manual layout inefficiency: Arranging the photos in a print layout 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:

  1. HEIC Converter: Batch converts HEIF images to standard formats (JPEG/PNG/WEBP)
  2. Layout Generator: Arranges images in grid layouts optimized for printing

HEIC to JPEG Conversion

Source: heic_converter

Key Dependencies:

  • pyheif: HEIF/AVIF decoder support via libheif
  • pillow (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

Source: layout_gen

Key Dependencies:

  • pillow: Image processing
  • reportLab: 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:

  1. Cropping Algorithm: Currently uses edge-based cropping without content-aware centering, meaning subjects near image edges may be cropped out.

  2. Uniform Sizing Constraint: All images in a layout use identical dimensions, requiring separate invocations if dealing with mixed aspect-ratios.