The rants and ravings of a Mac developer

Finding the original photo file in the iPhoto Library database

Using iPhoto’s SQLite3 database you can get the relative path to the original photo in the iPhoto library for any image in the sqPhotoInfo table. To do so you must join from the sqPhotoInfo table to the sqFileImage table and finally to the sqFileInfo table.

select pi.primaryKey, pi.archiveFilename, fl.relativepath
from SqPhotoInfo as pi
join SqFileImage as fi on pi.primaryKey = fi.photoKey
join sqFileInfo  as fl on fl.primaryKey = fi.sqFileInfo
where fl.relativePath like 'Originals%'