the codery

"jpeg impec" : a tool for JPEG images.

Download the script (zip 108 ko)

This script manages several issues of JPEG image manipulation: EXIF header, icons, rotation, Colorsync. Its goal is to improve compatibility between OS X applications and other software, specifically from Canon.

This script use the shell script "". It also uses two binaries, "jhead" and "jpegtran". All three files are included in the resources of this script and thus used transparently. The shell script "" is also available separately for use from command line.

It is itself used by the companion script, "jpeg impec i", specifically written for use from iPhoto. "jpeg impec i" is not currently public as it is tricky to use, due to iPhoto behaviour.


The first goal is to insert back an EXIF header in an image from which it has been removed or modified by an image manipulation program. It is the case for all Quicktime applications under OS X (Image Capture, Preview, iPhoto). They modify coding of headers and suppress some proprietary fields (e.g. from Canon). Photos are thus deprived of some shooting informations. If transferred back in the camera or on a memory card they are sometimes unreadable.

The original image file must have the same name as the processed file and be in a subfolder named "Originals". IPhoto automatically create this folder for originals of modified photos, including those automatically rotated while downloaded.

The script suppress the thumbnail embedded in the exif header. This thumbnail, of low quality, raise problems:

Rotation :

This script also able to rotate the image in a lossless process. This is not the case with iPhoto. One can revert to the original of iPhoto and then rotate it with this script. See instruction of the script for iPhoto: "jpeg impec i".

Icons :

A puzzle. Under OS X, there are several size of icons, and also a preview which is displayed by the finder in column mode or in the info window. This, added to the internal thumbnail of the EXIF header already mentioned. The situation comes close to absurd when one see that some other applications have their own preview format, not compatible with the Finder. Photoshop for example. iPhoto manage its thumbnail outside the image file.

By default, this script suppress all icons and thumbnails (not iPhoto's). We can live without, since the Finder generates them on the fly.

If you want icons, to speed up the display of the Finder in icon mode, the script has an option which relays on the Pic2Icon freeware (see address below). It does not generate previews of column mode. Some applications do, as ImageBrowser shipped with Canon cameras.

Beware: Icons and thumbnails are stored in the resources of image files, in an uncompressed format. They can significantly increase the size of the file and used disk space. iPhoto thumbnails are JPEG and use less space.

Colorsync :

Another puzzle. For a correct color rendering in OS X apps, itis necessary to include a Colorsync profile in the images. Otherwise they are too bland (for camera pictures). "Image Capture" can include a profile at download, but mess the exif header. It is better to do it latter with this script.

Warning:Colorsync operations are slow. To process a large number of images, it is better to run the script at idle time.

Usage :

The script is made to be run from the Finder. A companion script allows to use it from iPhoto. See "jpeg impec i".

There are three ways to run it:

Installation in Applescript menu:

Some parts of the code are borrowed from Apple examples.

Note to Canon camera users

To keep all shooting informations recorded by the camera, it's mandatory to import the photos with Canon's application ImageBrowser. Using iPhoto or "Image Capture" is possible but some information will be lost.

Conservative procedure :

  1. Import photos with ImageBrowser.
  2. Option: rename files, for example with ExifRenamer.
  3. Adjust with "jpeg impec" (rotation, Colorsync).
  4. Import pictures in iPhoto and suppress files created in 1.
  5. Modify photos, if needed.
  6. To get back complete EXIF in modified pictures, process with "jpeg impec" (dragging an icon from iPhoto to "jpeg impec" icon will open it without browsing in the iPhoto library)
  7. To see the full EXIF header, use ImageBrowser (dragging an icon from iPhoto to ImageBrowser's icon will open it without browsing in the iPhoto library).

Links :

jhead by Matthias Wandel
jpegtran by (IJG))

version 2.1: correct a bug if language is undefined or BSD not installed
version 2.0b: public version
version 1.x: unreleased