Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ChrisDolan (2855)

  (email not shown publicly)

Journal of ChrisDolan (2855)

Thursday August 13, 2009
09:33 PM

[non-perl] Hacking iPhoto via SQLite

[ #39457 ]

(a very off-topic SQL exercise follows...)

Apple's iPhoto 2009 has a very cool face recognition feature where it will show you faces and prompt you to enter names. When it finds resemblances, it will suggest names for you to confirm or reject.

When it's wrong, it makes for funny little screenshots you can send to friends: "Haha, cute girl! You look like an older heavier man!"

But once you reject the match, you can't undo or get it back in any other way. Luckily, iPhoto stores ALL of its metadata in a collection of SQLite databases. So, in the particular case that I linked above I was able to undo by telling the database not to ignore the marked mismatches from IMG_0095.JPG:

% osascript -e 'tell application "iPhoto" to quit'
% cd "Pictures/iPhoto Library"
% sqlite3 iPhotoMain.db
sqlite> select photoKey,relativePath from SqFileImage,SqFileInfo where sqFileInfo=SqFileInfo.primaryKey and relativePath like '%IMG_0095.JPG';
110|Data/2003/Roll 15/IMG_0095.jpg
110|Originals/2003/Roll 15/IMG_0095.JPG
3666|Data/2006/Apr 25, 2006/IMG_0095.jpg
3666|Originals/2006/Apr 25, 2006/IMG_0095.JPG
sqlite> .exit
% sqlite3 face.db
sqlite> update similar_faces set ignore=0 where image_key=110;
sqlite> .exit
% open -a

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I found one of the best/easiest ways to browse and edit data in SQLite files is... using the Firefox browser. With the SQLite Manager [] extension.

    It's insane, but Firefox uses SQLite intensely for its own purpose, and what this Firefox extension does is tapping into this potential.

    • Wow! What a great extension! Thanks for the recommendation. This advice alone justifies my blog posting. :-)