iPhoto – Removing redundant originals

I recently came across this article on slimming down an iPhoto library by removing the ‘Original’ photo where a ‘Modified’ one existed.

(That’s one part of what the free iPhoto Diet app does, but it seems that’s not being maintained and doesn’t support recent versions of iPhoto.)

Inspired by the basic three-line shell script in the article I worked up this somewhat more advanced version:

#!/bin/sh -ex
cd ~/Pictures/
du -sh 'iPhoto Library'
dest=$HOME/Pictures/iPhoto-Redundant-Originals-`date "+%Y-%m-%d-%H%M"`
# for all files in iPhoto Library/Modified/...,
# move the corresponding iPhoto Library/Originals/...
# files into a zip archive file
find 'iPhoto Library/Modified' -type f -print \
    | perl -pe 's{iPhoto Library/Modified/}{iPhoto Library/Originals/}' \
    | zip -9 -T -m $dest -@ 2>&1 \
    | grep -v 'zip warning: name not matched'
du -sh 'iPhoto Library'

It has some advantages over the original: the photos are moved into a unique zip file, rather than the trash, and the file hierarchy is preserved, so files can be restored easily.

It could be modified to only operate on a subset of files, such as those older than a certain age.

Extra notes:

  1. After running this you’ll find that the photo will appear black in the ‘edit view’. That’s not a problem. The ‘edit view’ (which you enter by double clicking on a photo, for example) reconstructs the final image by taking the original and reapplying the edits-so-far. Since the original file has been removed you’ll just see a black image. Don’t worry. In all the other views, and for printing etc., your final modified picture will appear perfectly.
  2. iPhoto handles automatic rotation of images from cameras that record their orientation by performing a rotation ‘edit’ for you when you import the image. That rotation creates a modified copy, and that’s a common cause of bloat in your iPhoto library. It’s also why you may be surprised to see some originals being archived even though you haven’t editied them. It would be nice if iPhoto had an option to handle rotations destructively.

Usual caveats: this worked for me, your mileage may vary, cross your fingers, read the referenced article (and follow the links in contains), read the comments on them, quit iPhoto, take a backup, wear a tinfoil hat.

5 thoughts on “iPhoto – Removing redundant originals

  1. Pingback: iPhoto - Removing redundant originals « Not this… | Mac Affinity

  2. This worked for me on iPhoto ’08 and OS X 10.5.7.

    Thanks for this scipt, it cleared out a lot of disk space, and so far my iPhoto library seems stable. I wish Apple would include an option like this in iPhoto though.

  3. What if the script where to check if there’s an original and a modified version of a file. And if so, have the script overwrite the original file with the modified version, after which the modified version can be deleted.

    That might sort the problem of the edit function not working anymore.

  4. I have a 75Gb iPhoto library, which I want to slim down to backup. The originals folder inside the package alone is 58Gb.

    I ran this script, it took ages and didn’t work:

    5076932815 extra bytes at beginning or within zipfile (attempting to process anyway) start of central directory not found; zipfile corrupt. (please check that you have transferred or created the zipfile in the appropriate BINARY mode and that you have compiled UnZip properly)

    test of /Users/richard/Pictures/iPhoto-Redundant-Originals-2010-11-11-1814.zip FAILED
    zip error: Zip file invalid, could not spawn unzip, or wrong unzip (original files unmodified)


  5. Just in case you want to reselect and delete photos from iPhoto, including the originals from the folder where they reside, I found a workaround. As you know emptying the trash in iPhoto does not delete the originals. For instance you can look at your photos and while you are doing it “flag” the ones you want to delete (see iPhoto’s Menu–>Photos–>Flag Photo for a shortcut). Once you have “flagged” all the photos you want to delete, then go ahead and select them all (in the left hand column of the iPhoto window there is a “Flagged” icon, right above the “Trash” icon – click on it and you’ll see al your flagged photos on the display window). Do a simple Edit–>Select All and then mouse-right-click on one of them and select “Show File”. This will open a window with the folder where your originals are located, and in this case the ones you want to delete will be already and conveniently selected for you. Then simply go ahead and trash them with your mouse or with the “Delete” icon on the Toolbar and voilá!. (if the Toolbar is not showing then simply select from the Finder menu View–>Show Toolbar).

Comments are closed.