How to replace images in iPhoto with higher quality versions? I use Aperture for photo editing and processing, but prefer iPhoto for keeping a gallery of my pictures. For a long time, I used the built-in tools in iPhoto to "Import from Aperture Library". What I didn't know was that this only imports the preview image, which is at a quarter resolution and badly compressed. I now have a couple of years worth of albums with lots of metadata but crappy image quality. I'd like to replace the images with higher-quality versions from Aperture, without losing all of the metadata (tags, descriptions, faces, etc). What's the easiest way to do this?

Related question: is it possible to access/change the image data in iPhoto with AppleScript? I can write a script to match images and replace them, if there's a mechanism to do that.
Here's how I eventually solved this problem. It took a few steps, and requires some scripting and command line hackery, but it did the trick.


Export the pictures you want to update from Aperture to a folder, say ~/Pictures/Updates
Open the album in iPhoto
Use this AppleScript to get a list of filenames for the master images

set output_filename to "/Users/user/Pictures/album.txt"

tell application "iPhoto"
    set pics to photos in current album
    do shell script "echo \"# Current album contents\" &gt; " &amp; output_filename
    repeat with pic in pics
        set picpath to image path of pic
        do shell script "echo " &amp; picpath &amp; " &gt;&gt; " &amp; output_filename
    end repeat
end tell

Using any text editor, save the script below to update_pics.sh and mark it executable (chmod 755 update_pics.sh on the command line)

#! /bin/bash
# a quick script to parse in a series of filenames, and update them

input_folder="$1"
backup_folder="$2"

if [ "$#" -ne 2 ]; then
        echo "Usage: $0 [folder with new images] [folder for backups]"
        exit 0
fi

if [ ! -d "$input_folder" ]; then
        echo "Can't read input follder $input_folder"
        exit -1
fi

if [ ! -d "$backup_folder" ]; then
        mkdir -p "$backup_folder"
fi

if [ ! -d "$backup_folder" -o ! -w "$backup_folder" ]; then
        echo "Can't write to backup folder $backup_folder"
        exit -1
fi

while read line; do

        # skip empty lines or comments
        [ -z "$line" -o "${line:0:1}" = "#" ] &amp;&amp; continue

        if [ -f "$line" ]; then
                filename=`basename "$line"`
                input_file="$input_folder/$filename"
                cp "$line" "$backup_folder"
                if [ -f "$input_file" ]; then
                        echo "Replacing $filename"
                        cp "$input_file" "$line"
                else
                        echo "Could not find input file $input_file"
                fi
        else
                echo "$line does not exist"
        fi
done

To use the script, give it the location of the updated pictures, a folder to put backups (I'm paranoid of losing data) and then pipe in the file generated before. For example:

update_pics.sh Updates/ Backups/ &lt; album.txt

If you haven't already, close iPhoto. Then restart it while holding down Option and Command. That should give you a dialog to rebuild the iPhoto. You should only need to rebuild the thumbnails, though you may want to rebuild everything else. More info on rebuilding the iPhoto Library from Apple


iPhoto will probably take a long time to rebuild the thumbnails, since it will redo all of them. You have a number of albums to do, it's probably best to update the pictures first, album-by-album, and then rebuild the library. That's what I did, and it worked pretty well.