iPhoto Diet

An freeware Applescript Studio application for use with Apple's iPhoto.

Developer: Martin Fuhrer < >
Contributors: Fabien Octave, Didier Guillion, Nathan Day (for NDAlias), Matthias Wandel (for jhead)

Minimum Requirements

  • PowerPC or Intel Mac
  • Mac OS X 10.3 (Panther) or later
  • iPhoto 4, 5, or 6 (iPhoto 2 may work, but is untested)

Download

iPhoto Diet 3.1
iPhoto Diet Source Code

Supported Languages (to be included in iPhoto Diet 3.1.1)

English - by Martin Fuhrer
French - by Didier Guillion
German - by Michael Nordmeyer
Italian - by Rosario Pignatelli
Russian - by Michael Krekin
Spanish - by Emmanuel Cáceres de Kerchove
Thai - by Zek Kelley
Ukraine - by Mykyta Glumov

iPhoto Diet and iPhoto 7.x (October 22, 2007)

Currently, there are several incompatibilities with iPhoto 7 which prevent iPhoto Diet 3.1 from running to completion. For anyone wondering whether an update to iPhoto Diet is in the works, the short answer is, yes! While the incompatibilities are fairly straightforward to fix, there are a couple items that will take a bit more effort to address.

First, iPhoto Diet code needs to be refactored into smaller files, as the current main Applescript file has grown to more than 5000 lines, causing XCode to persistently balk at compile time. Even if XCode 3 in Leopard supports larger Applescript files, code refactoring is a GOOD THING for code maintainability, and something I have been meaning to do for some time; the only downside is that it will take some time to retest all the code and make sure it works together from the smaller files.

Second, there are some long-standing bugs from the iPhoto Diet 3.1 release that require fixing, if at all possible. The most common bugs crop up as Applescript errors, and I have a list of these that I want to track down (and doing so should be fairly straightforward, just a matter of allocating some time, which has been in short supply earlier this year). The missing photo / grey screen problem that some users have encountered remains elusive, as I haven't been able to reproduce it on my Powerbook. I figure it may be related to something going amiss during GUI scripting, when iPhoto Diet attempts to control iPhoto by automating menu selections and button clicks in the iPhoto interface (because iPhoto doesn't provide sufficient Applescript support to carry out all of iPhoto Diet's actions behind the scenes, via Applescript commands). I intend to look into this issue further, but coming up with an ultimate fix isn't a certainty.

In any case, a new version of iPhoto Diet is underway, and will be released when it is ready. During the past few months I have received a couple hundred emails pertaining to iPhoto Diet progress, questions, and bug reports, and while I have tried my best to answer them all, time constraints prevent me from getting back to every one. If you did send me an email, but didn't receive a reply, please do understand that things have been a bit busy, and rest assured that I do actually read every message and take note of all requests, problems, and bugs.

Important Note On iPhoto Diet 3.1

I have received several reports of two significant problems in iPhoto Diet 3.1:

  • After using the "Remove Original Backups" options, if you attempt to edit a photo whose original had been removed by iPhoto Diet, you may end up with a grey screen and a dotted outline and exclamation mark where you expect your photo to be. If you select Photos > Revert to Original from the menu, your photo should come back (this should be the modified version, as iPhoto Diet will have moved the original to the Trash).
  • Upon starting the diet with "Unassigned Photos" or "Imported Duplicates" selected, you may receive an Applescript error "iPhoto got an error: Can't make type of album 1 into type reference."

These problems appear to affect only some users, and I am attempting to determine a cause and fix (I haven't yet been able to reproduce them on my Mac, but am working with some of the afflicted users to figure things out). The first problem, especially, highlights the importance of backing up your iPhoto library - in case something goes wrong, you'll be able to fast-track back to the way things were. I will keep this note updated as my investigations progress.

What is iPhoto Diet?

iPhoto Diet is a utility that helps to slim down your iPhoto library by manipulating your photos in the following ways:

  • eliminate duplicate photos created internally by iPhoto or imported by yourself
  • remove iPhoto's backups of rotated or modified photos
  • strip the thumbnail icons of your photos
  • remove thumbnail photos that have become mixed up with your high resolution photos
  • identify photos which have not been added to albums
  • weed out unnecessary folders and files from the library
  • and more!

These operations allow you to recover hard drive space and to fit more photos in an iPhoto library that you want to burn to a CD or DVD. iPhoto Diet supports multiple iPhoto libraries, and provides basic library management features such as switching and launching libraries. In addition, iPhoto Diet can be run manually or configured to start scanning your libraries automatically at desired times.

Precautions

iPhoto Diet actively manipulates the photos inside your iPhoto libraries. With iPhoto 6, iPhoto Diet may further manipulate photos outside your iPhoto library, if iPhoto has been set up to reference photos on your drive(s) rather than import them (see this section for more information). For maximum safety of your photos, you are encouraged to back up your iPhoto library folders and any other collections of photos referenced by iPhoto prior to running iPhoto Diet. After you successfully slim down your iPhoto libraries and check that everything is in order, you can remove your backups. Please note the disclaimer!

Installation

Drag the iPhoto Diet application to any desired location on your hard drive.

Quick Start

To get started right away:

  1. Launch iPhoto Diet.
  2. Add libraries to the iPhoto Libraries list.
  3. Select the library or libraries you wish to use.
  4. Select your dieting options from the "Operations" panels.
  5. Click "Start Diet".

As the diet proceeds, iPhoto Diet will automatically communicate with the Finder and iPhoto in order to weed out photos. You should not use iPhoto until the diet has finished. Be aware that iPhoto Diet may switch applications while it is running, preventing you from accomplishing other tasks on your Mac.

Getting Started

Double-click the iPhoto Diet icon to launch iPhoto Diet. If this is the first time you are using iPhoto Diet, your current iPhoto library will automatically get added to the iPhoto Libraries list.

If you are running Mac OS X 10.3 (Panther) or later, you should enable access for assistive devices in the Universal Access pane of System Preferences. This permits iPhoto Diet to make use of GUI scripting, a feature which is necessary for removing originals under iPhoto 5 or 6 and allows photo sort modes to be set for albums created by iPhoto Diet. GUI Scripting means that, occasionally, iPhoto Diet will take control over the interface by bringing iPhoto to the foreground, choosing menu items, and clicking buttons, so it may interfere with other work you are trying to accomplish on your Mac. Due to limitations in Applescript support in iPhoto, GUI Scripting is presently the only workaround for some of the tasks iPhoto Diet is trying to accomplish.

Adding, Launching, and Removing Libraries

iPhoto Diet has basic management features for working with multiple iPhoto libraries. If you have only one iPhoto library, you can skip over this section.

Add libraries to the iPhoto Library list by clicking the "+" button (or type Cmd-A) and selecting them from the Open dialog box. If you select an empty folder, iPhoto Diet offers to convert it into a new iPhoto library. You can also drag iPhoto library folders (or drag an empty folder) from the Finder directly onto the iPhoto Libraries list or onto the iPhoto Diet icon.

Libraries in the list are color-coded as follows:

  • Green: This is the current library which loads when you start iPhoto.
  • Black: This is an available iPhoto library.
  • Red: The iPhoto library is not available. Quite likely the library may have been deleted or moved to an unmounted volume or file share. By selecting File->Auto Mount, any libraries that reside on unmounted volumes or file shares will automatically get mounted.

Selecting a library will reveal its path in the status bar at the bottom of the window. Click the triangle-shaped Launch button (or type Cmd-O) to set this library as your current library and launch it in iPhoto. You can select multiple libraries by clicking in tandem with the Shift or Command keys.

To remove a library, select it in the list and click the "-" button (or type Cmd-R). This will remove the library from the iPhoto Library list only; the library will remain untouched in the Finder.

You can change the name of a library by double clicking it. Note that changing the name in the list view will not change the name of the library in the Finder.

Dieting Options - Finder Operations

All the options in the Finder Operations box directly manipulate photos and files in your iPhoto libraries by communicating with the Finder and performing UNIX-level file operations. Any photos that are removed from the libraries will be placed in the Dock's Trash. These operations act behind the scenes, targeting extraneous photos and files, so you will not notice any direct changes to your photos and albums when you load up the libraries in iPhoto. You will, however, notice iPhoto 5 or 6 jumping to the foreground whenever iPhoto Diet removes a photo.

Remove Original Backups

In order to fully understand these options you need to know a bit about iPhoto's inner workings. iPhoto automatically backs up original copies of your photos whenever you make changes, such as rotating an image, adjusting brightness, or cropping. This makes it possible to revert back to the original if you are unhappy with your changes, via the Photos -> Revert to Original menu item. These originals are kept inside one or more "Originals" folders in the iPhoto library and over time add greatly to the library's size.

The Remove Original Backups Options will only remove the backed-up originals photos inside the "Originals" folders. In effect, any modified photos or any photos that haven't been backed up by iPhoto in the first place (because you haven't yet modified them) will not be touched.

If you are running iPhoto 5 or 6 and wish to remove originals, you must turn on "Enable access for assistive devices" in the Universal Access pane of System Preferences. A detailed (and somewhat technical) explanation as to why this option must be enabled is here. iPhoto 5 and 6 use the "Originals" folders to store two additional file types: movie files and RAW images. These files act as master copies and will not be removed from the "Originals" folders under any circumstances.

You can selectively move originals to the Trash by enabling one of the three options below. To remove all originals in your iPhoto library, enable all options. Remember that if you remove all originals, you will be unable to revert to any original photos via the Photos -> Revert to Original command in iPhoto.

  • Redundant Backups: Removes all unnecessary backups. The backed-up original photo is exactly the same as the "modified" photo. Select this option if you have set up iPhoto to view photos in an external image program, as iPhoto will create a backup regardless of whether or not you make any changes.

  • Unrotated Originals: Removes the unrotated originals of pictures which you have rotated by 90 degrees. If your photos are in jpeg format, the unrotated original will usually have superior quality to the rotated image, which will be recompressed by iPhoto. In practice, though, the difference in quality may be barely visible, if at all. Select this option if you frequently take vertical shots. iPhoto 6 supports on-the-fly rotation, whereby the original is kept in its untouched, unrotated state, and instantly rotated when it is viewed, without requiring a rotated photo to be generated. Because iPhoto 6 saves a modified version as soon as you modify the size and coloration of the rotated photo, iPhoto Diet will still remove some unrotated originals, though typically not as many as in earlier versions of iPhoto.

  • All Others: Removes all original backups that are not caught by the first two options. These are typically the original backups of photos that you have modified with iPhoto's editing tools or an external application. If you perform a lot of cropping or color adjustments on your photos and don't wish to keep the originals, select this option.

Within iPhoto Libraries Only (iPhoto 6 only)

When checked, this checkbox tells iPhoto Diet to remove an original backup only if it resides inside the iPhoto Library. If you are running iPhoto 5 or earlier, photos (whether original or modified) always reside in the iPhoto library, and iPhoto Diet will always keep this checkbox checked. By default, iPhoto 6 also places all imported photos within the iPhoto library, but by unchecking "Copy files to iPhoto Library folder when adding to library" in the Advanced pane in iPhoto's preferences, iPhoto simply links to the imported photos wherever they may reside on your drive. If you make any modifications to one of these photos in iPhoto, a modified copy is stored inside the iPhoto library, and the original backup remains in its former location outside the library. When "Within iPhoto Libraries Only" is unchecked, iPhoto Diet will move the original photo outside the library to the Trash, and replace it with the modified photo from inside the library. If you do not want iPhoto Diet to be manipulating photos outside the iPhoto library, make sure to keep this option checked.

Other Options

The potential disk recovery of the following options is typically not as sizeable as the Remove Original Backups options, but you will be able to regain a bit of disk space and generally clean up your iPhoto library.

  • Strip Icon Thumbnails: This option does not remove any photos, but rather removes the icon thumbnails that are visible on photo files in the Finder. This is accomplished by removing the icon resource in the photo's resource fork, the portion of the file that stores scaled-down versions of the photo. Typically, the icon resource in a single photo file occupies 50 KB to 100 KB. Check this option if you rarely view the contents of your iPhoto library folders in the Finder. The pictures below exhibit before and after views (left and right respectively) for stripping icon thumbnails - note that previews are not affected. After stripping, thumbnails may continue to be displayed until you log out or reboot. If you ever want to regenerate your thumbnails, you can use a program such as Pixture Studio's QuickImageCM. Select this option if your digital camera or scanner saves your photos with thumbnails.

  • Remove Leftovers: Removes any stray files and empty folders which are no longer required or recognized by iPhoto. Stray file are moved to the Trash, and empty folders are immediately deleted. In addition, this option deletes any hidden "DS Store" files. "DS Store" files are used by the Finder to determine the custom layout of icons in a window, and are generally not required for iPhoto libraries since you view the photos in iPhoto rather than in the Finder.

Dieting Options - iPhoto Operations

Unlike the "Finder Operations" options above, these options manipulate photos solely via iPhoto's interface. Photos will be moved into new albums or iPhoto's Trash. In fact, if you look at iPhoto while these operations are taking place, you will likely see albums being created and photos being moved around before your very eyes. This is normal behaviour!

"Move" Options

Choose the photos you want iPhoto Diet to identify and move:

  • Unassigned Photos: These are photos which have not yet been assigned to a standard album (not to be confused with a smart album). Use this option if you have created all your customized albums and you want to get rid of your left-over photos. Alternatively, you can use this option to easily identify which photos haven't yet been used and assign them to your existing album collections. If you use iPhoto 4 or later, you may find it much faster to isolate your unassigned photos by using iPhoto's smart albums feature: just use the terms "album is not any" when creating your smart album.

  • Thumbnail Photos: iPhoto creates thumbnails of all your high resolution photos and stores them in the iPhoto Library. If you attempt to import photos from an existing iPhoto Library, you may accidentally import the low resolution thumbnails, such that they mingle together with your high resolution photos. This option will identify these thumbnails. To be identified as a thumbnail, the photo must have dimensions equal to or less than 240 by 180 pixels (iPhoto 5 or earlier) or 360 by 270 pixels (iPhoto 6), the "standard thumbnail dimensions" used by iPhoto. Furthermore, its backed-up original (if present) must have the same dimensions; this ensures that the photo is truly a thumbnail, and not just a cropped version of a larger photo. A note of caution: if you intentionally collect thumbnail-sized photos, you should not use this option, as iPhoto Diet has no way of knowing which thumbnails are the ones you intend to keep, and which ones were accidentally imported.

  • Imported Duplicates: These are duplicate photos (and movie clips, in iPhoto 5 and later) which you may have accidentally or intentionally imported into iPhoto at some point, so that you end up with two copies of the same photo visible in iPhoto's main Library. iPhoto Diet recognizes a duplicate by comparing the raw photo data of the two files in question and checking if it is exactly identical. If two photos appear the same visually, but use different compression settings or are of different sizes, iPhoto Diet may not be able to tag the duplicate (this situation may change if you enable compare timestamps - see below).

    Given two identical photos, how does iPhoto Diet determine which one to keep and which one to flag for removal as a duplicate? First, if one photo is in an album while the other is not, then the one in the album is considered a keeper. If neither photo is in an album, then the photo with the most recent file modification date is kept. In either case, if the photo that is flagged as a duplicate has comments and keywords while the keeper photo does not, then the duplicate photo's comments and keywords will be copied over to the keeper photo so that they are not lost.

    The search for imported duplicates can be further refined with the following options:

    • Compare Timestamps: Most digital cameras that save photos as jpegs will add a timestamp, describing the exact date and time when a photo is taken. The timestamp is stored as part of the photo's EXIF data, and normally remains unchanged even if you modify and resave the photo. You can view the EXIF timestamp for a selected photo in iPhoto by choosing Photos -> Show Info and reading the Original Date field (if this field is empty, then the photo does not have an EXIF timestamp). With the "Compare Timestamps" option selected, photos will be considered identical if their EXIF timestamps match. This means that a given photo along with its modified versions will be considered identical. Unfortunately, it also means that if two completely unrelated photos happen to have the same timestamp, down to the exact same second, they will also be considered "identical". While the chances of this happening are very slim, nevertheless, the possibility of misidentification exists.

    • Compare Originals: By default, iPhoto Diet does not take into account backed-up originals when it is comparing images for duplicates. It compares only the images you see in the main Library album of iPhoto. With the "Compare Originals" option turned on, if two images have been separately modified, but their backed-up originals happen to be identical, then iPhoto Diet will recognize the photos as duplicates. RAW images (iPhoto 5 and later) are treated as backed-up originals, so enabling "Compare Originals" forces iPhoto Diet to compare the RAW images directly, rather than the JPEG files which iPhoto generates from the RAW files.

    • Relink Albums: Album relinking is a useful feature if both your keeper and duplicate photos appear in albums. With album relinking, iPhoto Diet is able to replace the duplicate photos in your albums with the keeper photos, so your albums don't lose any photos when you delete the duplicates.

      Perhaps this is best explained with an example: suppose you have two identical photos in your library, titled Joe-1 and Joe-2. Let's also assume that you have two albums, "Friends" and "Christmas Party", and that you have placed Joe-1 in "Friends" and Joe-2 in "Christmas Party". If iPhoto Diet tagged the photo Joe-2 as a duplicate, you would find the picture of Joe missing from the "Christmas Party" album once you have removed your duplicates. To prevent such album shrinkage, iPhoto Diet will create a copy of the album titled "Christmas Party (Relinked)", in which Joe-2 is automatically replaced with the identical keeper photo Joe-1.

      Album relinking may add a considerable chunk of time to the diet, especially if you have many albums. It is important to note that there is no "Relink Books" or "Relink Slideshows" feature, due to limitations in iPhoto's scripting libraries. If your books or slideshows happen to use duplicate photos, they will not be replaced by keeper photos upon deletion of the duplicates.

"To" Options

Choose where you want iPhoto Diet to move the photos:

  • New Album: Identified photos will be moved into one or more new albums (described below) which you can easily review. The names of any new albums iPhoto Diet creates begin and end with double-dashes ( -- ) in order to differentiate them from the rest of your albums.

  • iPhoto's Trash: Identified photos will be moved directly to iPhoto's Trash.

Executing your Diet

After you have selected your libraries and dieting options, click the "Start Diet" button (or type Cmd-S). The progress of the diet will be displayed in the window's status bar. You can abort at any time by clicking "Stop Diet" (or type Cmd-S). Any photos that have already been moved to the Trash or a new album will remain in their new location.

The amount of time required for the diet varies depending on the options you chose and the size of your library. Be prepared to spare several hours of computing time for very large libraries (you may wish to let iPhoto Diet run overnight while you are sleeping).

iPhoto Diet relies on iPhoto to execute most of its options (only "Strip Icon Thumbnails" and "Remove Leftovers" do not require iPhoto's services). iPhoto Diet will automatically launch iPhoto as required. If you have selected more than one library, you will notice iPhoto quitting and restarting to load each of the libraries.

Furthermore, if you have enabled access for assistive devices in Universal Access, you will notice iPhoto jumping to the foreground occasionally, as iPhoto Diet performs menu operations directly in iPhoto. If you are removing originals under iPhoto 5, you will notice a Revert to Original dialog box popping up and being dismissed in rapid succession. This is normal behaviour, and is discussed in detail below.

Post-Diet Review

Once the diet is finished, iPhoto Diet informs you of the number and total size of photos that have been identified for each of the selected dieting options. Here is where your photos will have ended up.

Dock's Trash

This is where you'll find photos or files removed by the "System Operations" options. Control-click the Trash and choose Empty Trash to permanently remove them.

iPhoto's Trash

Any photos identified by "iPhoto Operations" will be moved to the Trash in iPhoto, if this is what you specified in the "To" options. Choose iPhoto -> Empty Trash to get rid of them. You can also restore photos in the Trash back to their original locations in the library and albums by choosing Photos -> Restore to iPhoto Library.

If you performed your diet on more than one library, you will need to launch iPhoto and empty the Trash for each separate library.

New Albums

Photos identified by "iPhoto Operations" will be moved to one of three new albums, if this is what you specified in the "To" options:

  • Unassigned photos are moved to -- Unassigned --
  • Thumbnail photos are moved to -- Thumbnails --
  • Imported duplicates are moved to -- Duplicates (Remove) --

You can review these albums in iPhoto to make sure that iPhoto Diet identified the correct photos. If imported duplicates are found, iPhoto Diet will generate an additional album named --Duplicates (Keep) --. This album contains all the keeper photos, for the purpose of comparison with the duplicates. If you did not enable assistive devices in Universal Access, you should select View -> Sort Photos -> Manually for both albums before comparing the photos. This way, the first photo in the Keep album corresponds to the first photo (its duplicate) in the Remove album, the second photo in the Keep album corresponds to the second photo in the Remove album, and so on.

By selecting all the photos in one of these three albums and pressing Command-option-delete, you can move these photos to iPhoto's Trash. If you rather not delete the photos, simply delete the albums.

Relinked Albums

You can easily identify all relinked albums by looking for albums with "(Relinked)" appended to the name. If you decide to delete your imported duplicates, you should replace your original albums with the relinked albums.

iPhoto Diet attempts to maintain the same manual ordering of photos in the relinked albums as in the original albums. If the ordering appears differently, you may need to select View -> Sort Photos -> Manually for the relinked album (this is automatically done if you have enabled assistive devices in Universal Access).

Can iPhoto Diet be set to run automatically at predefined intervals?

By clicking the "Auto Start" option, iPhoto Diet will automatically begin scanning the selected libraries using the currently selected options at the next launch. Using this feature in combination with crontabs, you can have iPhoto Diet run automatically at particular times of the day or week, such as night time when your Mac is likely to be sitting idle. In this way you can keep your iPhoto libraries slim and trim without any further intervention from yourself.

Umm... cron-what?

Cron is a UNIX scheduling facility used by Mac OS X to execute commands, such as opening applications, at predefined times. The commands can be placed in a system crontab file (in /etc/crontab) or in a user crontab file (in /var/cron/tabs/). Although crontab files can be edited by hand, a nice alternative is to use CronniX, a graphical frontend for the cron facility. If you are unfamiliar with crontabs, the help pages for CronniX give a good introductory overview.

Supposing you want iPhoto Diet to run every morning at 4:30 am, enable the "Auto Start" option and add the following entry to your crontab:

Min Hour Mday Month Wday Command
30 4 * * * /usr/bin/open -a "iPhoto Diet"

Similarly, to run iPhoto Diet every Tuesday at 10:15 pm, you would add the following entry:

Min Hour Mday Month Wday Command
15 22 * * 2 /usr/bin/open -a "iPhoto Diet"


In CronniX, these entries would appear as follows:

Why does iPhoto Diet generate a sproingy sound while scanning photos?

This sound is the Mac's Trash can sound, played whenever the diet in progress moves a photo to the Dock's Trash. If the sound is driving you batty, you can turn it off in your System Preferences: Open the Sound panel, click on the Sound Effects tab, and uncheck "Play user interface sound effects."

Can I continue to use iPhoto while iPhoto Diet is running?

As a rule of thumb, no. Unlike earlier versions, iPhoto Diet 3 and later is very tightly integrated with iPhoto. In essence, iPhoto Diet masquerades as a user and actively manipulates iPhoto. As a result, you should not use iPhoto until the diet has finished, or else you may interfere with iPhoto Diet's operations.

During dieting, why does iPhoto display "Revert to Original" messages when I have instructed iPhoto Diet to remove originals?

These "Revert to Original" dialog boxes are rapidly displayed and dismissed by iPhoto Diet while it is removing original photos. This behaviour is normal, and is described in detail here.

Why does iPhoto keep prompting me with "Locate original photo" dialogs while iPhoto Diet is running?

When iPhoto 6 catalogs photos that reside outside your iPhoto library, and some of these photos have gone missing (either you have deleted them or moved them to another drive), iPhoto requires a bit of help from the user to determine where the original photo has ended up. Because iPhoto Diet constantly queries iPhoto for information about all its photos, iPhoto will pop up a "Locate original photo" dialog when the photo in question cannot be found. You will either have to manually locate your photo or cancel the dialog before iPhoto Diet will be able to continue.

iPhoto Diet reports that errors were encountered during the diet. What does this mean?

If iPhoto Diet reports that it encountered errors during the diet, it usually means that iPhoto provided insufficient or incorrect information about a photo (eg. iPhoto may have returned a non-existant path). If iPhoto Diet is unable to make use of this information, it skips the photo and counts the incident as an error. The error is automatically logged to the "iPhoto Diet.log" file in the Logs folder of your Libraries folder. The occurence of errors suggests that your iPhoto library's database may be corrupt, or there may be a bug in iPhoto's Applescript libraries.

Is iPhoto Diet available in my language?

Thanks to the effort of individuals who have provided their time and translation skills, iPhoto Diet includes localization files in several languages. If iPhoto Diet does not open with your language, most likely no translation has been made, or an earlier localization has become outdated. Anyone is welcome to add a new language localization or update an existing localization. Please contact me if interested.

What if I encounter problems?

If iPhoto Diet presents any problems, such as crashes or AppleScript error messages, please let me know. The following pieces of information will help me to track bugs:

  • the version number of Mac OS X and iPhoto Diet
  • the wording of the error messages
  • iPhoto Diet.log: Enable the File -> Log Mode menu item. Begin the diet. After the error occurs send me the log file titled 'iPhoto Diet.log' located in ~/Library/Logs. The log contains information about the files in your iPhoto library and indicates the last files scanned before an error occured.
  • Console messages: Open the Console application in your Utilities folder, select File -> Open Console Log, and copy and paste the last few pages of text containing "iPhoto Diet" messages.
  • Mac OS X crash log report (if crash logging is turned on in the Console application)

You can also reset iPhoto Diet's preferences to their default state by selecting File -> Reset Preferences. This will reset the Dieting Options and iPhoto Library list.

If you have any comments or suggestions for improvements, I'd be happy to hear them.

Known Issues

The following list indicates several problems I am aware of :

  • The Compare Timestamps feature currently only works with JPEG files.
  • "Connection is invalid" errors may appear while iPhoto Diet is trying to interact with iPhoto. Usually this means that iPhoto Diet is issuing commands too rapidly for iPhoto. I am continuing to investigate ways of eliminating these errors.
  • If you have "Relink Albums" enabled and your iPhoto library (iPhoto 5 or earlier) contains smart albums, iPhoto Diet will try to relink the smart albums, which is really an unnecessary step, since smart albums are self-organizing. Unfortunately, the album concept in iPhoto's Applescript dictionary does not distinguish between smart albums and regular albums, so there is no way to avoid this redundancy. iPhoto 6 resolves this issue.
  • iPhoto Diet may sometimes produce errors if the filenames of photos contain non-Westernized characters. This is likely an issue with the current version of Applescript and should be resolved in future Mac OS X updates.

Can I make a donation?

iPhoto Diet is free software, and is my way of saying "thank you" to the many free software and open source projects available for the Mac. That said, I will gladly accept donations if you are feeling generous and would like to provide further incentive for its development.

"I went to a diet doctor and in just two months I lost $300!" (Fozzie double checks his script - he doesn't get it!)
- Fozzie Bear, The Muppet Show

On iPhoto, Originals, and GUI Scripting

The following is a technical discussion on the changes required to update iPhoto Diet in order to properly remove originals in iPhoto 5 and 6 libraries. Note that the information about iPhoto's behaviour is based solely on observation, and may not be completely accurate, as Apple does not release any specs on the inner workings of iPhoto.

Prior to iPhoto 5, removing backed-up originals from the iPhoto library was a simple affair: you simply removed the image from the "Originals" folder. When you selected the corresponding modified image in iPhoto, iPhoto would immediately scour the "Originals" folder and detect that the backed-up original is no longer present. iPhoto would then disable the Photos -> Revert to Original menu command, and be done with it. You could further modify the photo, and iPhoto would place a new copy of the photo (just before you started the new modifications) in the Originals folder, so you would have a safety net to fall back upon in case you wanted to throw out your new modifications. iPhoto Diet's happy, iPhoto's happy, and all's well in the world.

iPhoto 5 appears to have changed its handling of originals. It now keeps track of original folders in its own database, the Library.iphoto file. If you remove a backed-up original without notifying iPhoto, iPhoto consults its database and thinks the original still exists. If you select the corresponding modified image in iPhoto, you'll notice that the Photos -> Revert to Original menu command is still active. The problem is, in reality there is nothing to revert to. When you select Revert to Original, and the original is missing, iPhoto won't do anything. This is potentially misleading for the user, who may think the photo has been reverted when nothing actually happened.

In order for iPhoto Diet to remove backed-up originals in iPhoto 5 or later, it must let iPhoto know which originals have been removed, so that iPhoto can update the database. Normally, this is easily accomplished using Applescript, but iPhoto does not provide any Applescript commands for removing originals. So a bit of fancy manipulation is in order: iPhoto Diet now moves the backed-up original to the Trash, and then copies the modified photo to the Originals folder. The idea is to get iPhoto to revert to the original, but because the "original" is now the modified photo, iPhoto will simply copy the original back over the identical modified photo. The point is, this operation will force iPhoto to update its database, so it knows the backed-up original has now been removed.

A remaining obstacle is how to tell iPhoto to revert to the original. No such Applescript command exists. The only solution is to use GUI scripting, a feature introduced in Panther which allows a program to manipulate another program's menus and buttons directly. With GUI scripting, iPhoto Diet can select the Revert to Original command and click through the resulting "Are you sure you want to revert?" dialog box. Of course, such direct power over an interface can be a bit of a security risk, and Apple keeps GUI scripting disabled by default. To turn it on, you need to tick "Enable access for assistive devices" in the Universal Access Pane of System Preferences.

The drawback to GUI scripting is that the commands will take control of your Mac's interface. The consequences of working with your Mac while GUI scripts are running is akin to two users trying to use two mice and two keyboards on one system simultaneously. Hence, if you are using iPhoto Diet's "Remove All Originals" or "Remove Selectively" options in tandem with iPhoto 5 or 6 (this does NOT affect users of earlier versions of iPhoto), you may find iPhoto rudely jumping in front of the windows you are currently working in, so that iPhoto Diet can issue several interface commands. I wish there was a better way around this, but until Apple can provide a Revert to Original Applescript command, or move away from their "keep-track-of-originals-in-the-database" scheme, this is an inconvenience you'll have to bear with... or maybe not.

If you use iPhoto 5 or later and are not bothered by the fact that the Revert to Original menu item is selectable even if the original has been removed, you can bypass iPhoto Diet's slower GUI scripting method by entering the following command in the Terminal.

defaults write "iPhoto Diet" originals_fast 1

This will force iPhoto Diet to remove the originals without resorting to GUI scripting to select the Revert to Original command. Turn off this feature by using the same command, except replace 1 with 0. Note that iPhoto Diet automatically uses the fast method of removing originals for iPhoto 4 and earlier, where this method is completely safe.

Disclaimer

I wrote iPhoto Diet as a utility for personal use, but found it useful enough to release to the iPhoto community. To my knowledge, iPhoto Diet functions as it has been described above. There may, however, be unforeseen errors that result in unintended data loss or damage. I have only had a chance to personally test iPhoto Diet on my own PowerBook G4, and there is no guarantee that it will properly function on all Mac systems. Use iPhoto Diet solely at your own risk. For maximum safety always back up your iPhoto library before using it with iPhoto Diet.

When people’s houses are on fire, what’s the first thing they save after their pets and their loved ones are safe? The family photos.
-Sy Parrish, One Hour Photo

Version History

3.1 (September 10, 2006)

  • iPhoto 6 is now supported .
  • iPhoto Diet is now a universal binary.
  • Reorganized "Remove Original Backups" options.
  • Added the option to remove originals within iPhoto libraries only (relevant only to iPhoto 6)
  • All albums created by iPhoto Diet now begin and end with double-dashes ( -- ) to make them stand out from the user's albums.

3.0.8 (October 14, 2005)

  • Unrotated originals are now properly removed from the library.
  • Fixed Unicode text conversion errors for photo paths containing foreign characters.
  • Fixed a problem in Jaguar where a user was asked to locate "Image Events.app".
  • Added Thai localization (thanks Zek Kelley).
  • Added Ukraine localization (thanks Mykyta Glumov).

3.0.7 (July 7, 2005)

  • Fixed a bug where all originals would be removed if "Unrotated Originals" is selected under Mac OS X 10.4.1.

3.0.6 (May 13, 2005)

  • Documentation is now bundled within the iPhoto Diet application and available via the Help menu.
  • Fixed a problem where iPhoto Diet was unable to switch libraries if the library path contained parentheses.
  • Fixed several undefined variable errors.
  • Imported Duplicates is now enabled by default for first-time users.
  • When creating a new library with iPhoto 2, the library is now properly added to the iPhoto Diet's library list.
  • Fixed a Tiger-related issue that could produce a "no such file or directory" error while removing originals.
  • When duplicate photos are found using the Compare Timestamps option, the photo with larger dimensions is now kept.

3.0.5 (April 12, 2005)

  • Identified duplicates are now moved to the Duplicates album during the scan, rather than after.
  • Localized versions of iPhoto Diet and iPhoto will now properly move originals to the Dock's Trash.
  • Fixed a stall that occurred when pressing "Cancel" in some dialog boxes.
  • Fixed a Finder error that occurred when running iPhoto Diet under Jaguar.
  • Fixed an error that occurred when iPhoto generated an empty path to a photo.
  • Fixed a "cannot convert to alias" error that affected certain systems.
  • Various optimizations, code tweaks, and miscellaneous bug fixes.
  • Added German localization (thanks Michael Nordmeyer).

3.0.4 (March 15, 2005)

  • Fixed a problem where the current library would not be highlighted in green.
  • Resolved a situation where an iPhoto library could accidentally be added twice to the iPhoto libraries list.
  • Fixed an "alias" error that occured on some systems with "Remove Leftovers" enabled.
  • All empty folders will now be detected and removed in one sweep when "Remove Leftovers" is enabled.
  • Addresses "AppleEvent timed out" errors that could occur while removing originals.
  • Addresses possible misidentification of duplicate photos by checking for invalid photo files with a size of 0 kB.
  • Improved compatibility with iPhoto libraries created by iPhoto Override.

3.0.3 (March 5, 2005)

  • iPhoto Diet now notifies other iApps whenever you switch your current library.
  • Addresses "alias" errors by ignoring invalid photo paths returned by iPhoto.
  • Reports number of errors and log mode status in statistics panel after the diet.

3.0.2 (March 2, 2005)

  • Code optimizations: "Starting diet" phase runs significantly faster, plus smaller speed-ups in other areas.
  • Improved reliability when launching and switching iPhoto libraries.
  • Fixed an error involving a "fileSize message".
  • Checks for missing paths that may be returned by iPhoto and issues a warning.
  • Fixed a rare miscalculation in the removal statistics that could occur when "Remove All Originals" was selected.
  • Fixed a problem where text in the status bar could become garbled when switching applications while iPhoto Diet is running.
  • Modified criteria for identifying thumbnail-sized photos: photo must be 240x180 or smaller, and have the same size as the backed-up original (if present).

3.0.1 (March 1, 2005)

  • Fixed an "Image Events" error for Jaguar users.
  • Fixed an error stating "Library:Logs" could not be found.
  • New libraries can now be properly created while iPhoto is running.
  • Fixed an integer conversion error.

3.0 (February 28, 2005)

  • iPhoto 5 is now supported.
  • iPhoto Diet now operates in parallel with iPhoto to permit many new dieting options.
  • Added the "Imported Duplicates" option to remove duplicate photos imported into the current iPhoto library folder.
  • Added the "Unassigned Photos" option to identify photos which have not yet been assigned to albums.
  • Added the "Thumbnail Photos" option to identify thumbnail-sized photos which have been accidentally imported from another iPhoto library.
  • Added the "Remove Leftovers" option to get rid of empty folders, hidden "DS Store" files, and any stray files in the iPhoto libraries.
  • Libraries can now be created and launched from within iPhoto Diet.
  • Fixed a bug which would sometimes cause added libraries to appear as a blank line in the iPhoto Libraries list.
  • Issues a warning if the installed version of iPhoto is unsupported.
  • Added tooltips help system.

2.1.6 (January 16, 2004)

  • Added German localization (thanks to Karl Friedrich Winter).
  • Minor interface tweaks and formatting changes.

2.1.5 (November 25,2003)

  • Added proper support for long file names.
  • Fixed encoding of characters in Italian localization.

2.1.4 (November 18, 2003)

  • Fixed an error that occurred when iPhoto Diet started in Auto Mode with no selected libraries.
  • Resolved a "Descriptor type mismatch" error that appeared on some systems.

2.1.3 (November 11, 2003)

  • Fixed several Panther related bugs eg. no more "Some data was the wrong type" errors.
  • iPhoto Diet now quits automatically if Auto Mode was active at launch.
  • Minor interface tweaks made to the progress bar.
  • Translated documentation is now included with the download.

2.1.2 (November 2, 2003)

  • Small corrections and additions to help system (thanks to Didier Guillion).
  • Bundled Italian localization (Rosario Pignatelli) with the application and added French localization (Didier Guillion).
  • Log Mode no longer sends current log file to the Trash.
  • Fixed initial position of window (thanks to Didier Guillion).
  • Successfully tested with OS X 10.3 Panther (thanks to Didier Guillion).

2.1.1 (July 24, 2003)

  • Added internationalization support.
  • Minor optimizations to scanning of libraries.
  • Closing the window now quits iPhoto Diet.

2.1 (July 16, 2003)

  • Added an Auto Start option to begin diet automatically when iPhoto Diet is launched. Allows diets to take place periodically when used in conjunction with crontabs.
  • Window can now be resized.
  • Old debug logs lurking in the iPhoto libraries are moved to the Trash.
  • Minor improvements to interface and code.

2.0.2 (April 21, 2003)

  • Default iPhoto Library is automatically added to the libraries list on first run.
  • iPhoto Diet adaptively adjusts its scanning speed to eliminate some Image Capture Scripting errors.
  • Added "Reset Preferences" menu item to reset diet options, library list, and hidden preferences.
  • Thumbnails are now removed for originals as well as modified photos.
  • Size of photos and thumbnails removed is now displayed in MB if size exceeds 10000 KB.

2.0.1 (April 14, 2003)

  • Pathnames containing an apostrophe are now properly handled by the shell script commands.
  • Debug log file is properly closed when the "Stop Diet" button is clicked.
  • Fixed a bug where iPhoto Diet would erroneously report that a shell command is missing.
  • Fixed erroneous alerts displayed when a library already in the list would be added again.
  • Updated some of the help messages.
  • Changed alphanumeric sorting of libraries in list view from case sensitive to case insensitive.

2.0 (April 12, 2003)

  • Added compatibility for iPhoto 2 libraries.
  • iPhoto Diet is now an Applescript Studio application (It was previously an Applescript droplet.)
  • Added an iPhoto Library list view that stores library paths.
  • Multiple iPhoto libraries can be scanned at once.
  • Progress of library scans is displayed.
  • Added "Strip Icon Thumbnails" option for removing the resource fork of photo files.
  • Added help messages within the application.

1.0.3 (January 13, 2003)

  • Changed Debug mode to Log mode, so it doesn't sound as sinister to non-programmers :-)
  • Applescript version checking ensures that minimum requirements are met.
  • Scanning empty folders no longer results in an error.
  • Stray files located anywhere in the library are moved to the trash if "Remove orphans" is turned on.

1.0.2 (October 7, 2002)

  • Fixed a crash bug related to hidden files (.*) that may exist in subfolders of the iPhoto Library folder.
  • Fixed a bug producing the error message "Can't make <pathname> into an item" on some systems.
  • Added Debug mode which produces the file iphotodietdebug.log for debugging purposes.
  • All images rotated by 90 degrees are now correctly identified.
  • Added a current settings panel to view the selected preferences.

1.0.1 (October 5, 2002)

  • Removed the requirement for Tanaka's System OSAX. Thanks Fabien Octave!
  • Fixed a crash bug related to hidden files (.*) that may exist in the iPhoto Library root folder.

1.0 (September 18, 2002)

  • Initial release.


Counter courtesy of bCentral
iPhoto is a registered trademark of Apple Computer Inc.