In my spare time I do the layout for the Haarlemmer Wielen, the quarterly magazine of the Fietsersbond, afdeling Haarlem en Regio. Since this year we changed to a full colour glossy, which is a lot less forgiving about colour, colour space and image resolution. One of the first things I was looking for was a way to automate conversion of the photos I get from the authors. I looked at a few different options.
What I want to automate
There are a couple of things I would like to automate:
- Convert to the correct colour space Generic CMYK
- Convert all images to TIFF
- Set the image resolution to 300 dpi
The first point is a requirement of the printer for correct printing, I’d expected that InDesign would handle it for me, but when we submitted a document without the images converted I got a warning. The quality of the conversion of the image to CMYK is important, since the authors would expect their images to look the same in print as on the screen.
Conversion to TIFF format is not necessary if the image is not changed any further, but if you want to preserve image quality while editing you need to convert to a lossless format. There are two good options, PNG and TIFF. However TIFF is most used in the printing world so I decided to stick with that.
Finally the change of the resolution in the image is purely a convenience. The EXIF information of a photo almost always specifies a resolution of 72dpi or 96dpi. Resolution in an image doesn’t have a real meaning, but it is interpreted as an intent by InDesign. So when placing a photo in an InDesign document it will calculate the size of the image based on the pixel size and the dpi setting. The printer specified that images should be rendered with at least 300 dpi, so I set the resolution in the image to 300dpi, so I get the correct image size in centimetres when I placing the image.
ImageMagick
ImageMagick does not come standard with Mac OS X, but is easily installed with HomeBrew:
brew install imagemagick
ImageMagick is a command-line utility and is therefor well suited for automation. The tool can convert everything in one go:
convert image.jpeg -density 300 -colorspace cmyk image.tiff
It produced small images, but I had some issues with it reading some files. Also it is unclear which CMYK colour profile is used, so I cannot trust that it will do everything correctly.
Photoshop
I used Photoshop CS5.1. It allows scripting and batch processing, but I find Photoshop to be very slow to start up, and I didn’t manage to invoke a script as a stand-alone action. Photoshop can use the Apple ColorSync profiles, but also comes with its own profiles. The output quality from Photoshop is good and it manages this while still producing relatively small files.
ColorSync with Automator
Apple ships Automator a tool to automate repetitive tasks in Mac OS X since Tiger (10.4), so I was interested in try this out. It supports applying a Colour profile and converting an image to TIFF, however it doesn’t support setting the image resolution. Since you can run arbitrary shell scripts as part of a automator workflow this capability can be easily added. For my first attempt I tried to do this with ImageMagick, but that reintroduced my problem that the script would fail on some images.
Another issue I found while experimenting with Automator is that it sometimes failed without a clear reason. Digging in the error logs I found out that it had a problem writing to the output directory. After deleting and recreating the output directory it would work again.
SIPS
Looking for a way to interact more directly with ColorSync I opened one of the provided AppleScripts for ColorSync and found out that it used a command-line tool called sips. The name sips stands for Scriptable Image Processing System. Since it is the command-line part for ColorSync it makes use of the same Quartz engine and colour profiles as ColorSync. With the command-line options in ColorSync I managed to do everything in one go:
sips --deleteColorManagementProperties \ --matchTo "/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc" \ --setProperty dpiHeight 300.000 --setProperty dpiWidth 300.000 \ --setProperty format tiff --setProperty formatOptions lzw \ image.jpeg --out image.tiff
The command-line is a bit verbose, but it works and so far has proven to be a fast and reliable performer.
Conclusions
Of the options discussed I ended up using sips. It has a couple of advantages:
- It comes with the system
- It is fast
- It can do everything in one go
The only disadvantage I found so far is that the images it writes are larger than the files from Photoshop or ImageMagick, but at least I’m certain that the files are in a format that is handled well by my entire tool chain.