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:

  1. Format incompatibility: HEIF (.heic) files from iOS Live Photos were not supported by the printing layout software I had installed
  2. 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:

  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

GitHub: 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

GitHub: 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 when dealing with mixed aspect ratios.