/photofinish

A tool for processing digital images in the (presumably) last stage of publishing a photo

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Photo Finish is a set of command-line tools for automatically processing digital images with a focus on film scans. The eponymous photofinish crops, scales, and converts images in the (presumably) last stage of publishing a photo. I run a "hybrid" work-flow that starts with film scans, but this could also be of use to digital photographers.

A second tool, process_scans converts original TIFF scans into PNG or JP2 (JPEG 2000) files, in a sub-directory, and produces scaled previews. The conversion is useful because most software working with TIFF files does not use any compression. Saving 10~20 MB might not sound like much, but after scanning a whole roll of film (36+ exposures) it quickly adds up. Producing scaled previews and moving the originals to a sub-directory is useful because many programs want to create thumbnails of image files and this can be a very slow process with large, high-resolution scans (e.g ~120 MB each), especially over a network. So use the previews to identify a scan and open the original file manually.

The rest of this page deals primarily with photofinish, although all tools use the same library of classes.

Table of Contents

Description

So what does Photo Finish do?

  1. It decides on the correct cropping window for a specified "destination"
  2. Does the crop and rescaling
  3. Saves the result with custom EXIF/IPTC/XMP metadata

Features

My focus has been on image quality and correctness, so many computations are done in floating-point. The 1990's are long passed, so why limit ourselves to small integers? We have the computational power and memory storage to easily do this the right way.

  • The list of "destinations" is read from a YAML file
    • Destinations describe the size, format, and other specifics of the output
  • Each input file can have its own list of "tags" - EXIF/IPTC/XMP metadata, as well as "variables", some of which override destination parameters
    • This is an artefact of my original shell script (which used exiftool) and expanded in my Perl version (using Image::Exiftool); perhaps this should be replaced by YAML?

Image file formats

  • Reads and writes JPEG, PNG, TIFF, JP2 (JPEG 2000), WebP, JPEG XR (JXR) files
  • Supports having an alpha channel in PNG, TIFF, WebP, JPEG XR files
  • Embedded ICC profiles are used when reading, and created when writing
  • Falls back to sRGB or a similar greyscale profile
  • Reads CMYK image data from JPEG and TIFF files (requires an embedded ICC profile)

Data structures and processing

  • Before rescaling, image pixel data is transformed into the CIE L*a*b* colour space using floating-point components
    • This colour space is perceptually uniform, so it is ideal for rescaling of images
    • Even when the input and output(s) are greyscale, this colour space is used (partly for simplicity, but also because greyscale can have colour to it)
    • Configurable as either single or double precision at compile-time (DP adds almost nothing in my limited tests)
  • Rescaling is done using a Lanczos filter
  • OpenMP is used in several places to take advantage of SMP systems

Current limitations

  • Probably only compiles on Linux for now

Todo

  • Add other image formats e.g RAW formats (reading only)
  • Use YAML (or something else?) for the "tags" format
Crazy idea:
  • An entirely workqueue-based version to keep multiple processors/cores busy at all time

Libraries

Photo Finish currently uses the following libraries:

License

Copyright 2012-2013 Ian Tester <imroykun@gmail.com>

Photo Finish is licensed under the GNU GPL version 3 or later.