Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

where can I find information on iPhoto Library SQLite schema , i.e. major tables relationships

Hi there,


In a Ruby script, I need to request all pictures from a specific album ... I can get all albums contained in a specific folder ( RKFolder table) , but then when I get a specific album from the RKAlbum table , I don't know how to request a list f all photos within this album .. I don't see how the RKMaster table is related to the RKAlbum table ...

Is there any doc available ?


thanks


IPhoto 11 - v 9.6.2

MacBook, Mac OS X (10.7.5), also Mac mini 10.8

Posted on Mar 23, 2015 6:06 AM

Reply
Question marked as Best reply

Posted on Mar 23, 2015 7:20 AM

Being proprietary software Apple, to my knowledge, has never released the specs for the databases for iPhoto or Aperture.


It will need to be reversed engineered. You can do a web search to see if anyone has done that and posted their results or else you will need to do it yourself.


Given the demise of both iPhoto and Aperture it would be nice if Apple were to put all that out in the public domain but it is highly unlikely that that will ever happen.


good luck

14 replies
Question marked as Best reply

Mar 23, 2015 7:20 AM in response to kadoudal

Being proprietary software Apple, to my knowledge, has never released the specs for the databases for iPhoto or Aperture.


It will need to be reversed engineered. You can do a web search to see if anyone has done that and posted their results or else you will need to do it yourself.


Given the demise of both iPhoto and Aperture it would be nice if Apple were to put all that out in the public domain but it is highly unlikely that that will ever happen.


good luck

Mar 23, 2015 9:47 AM in response to GeoCo

I totally agree... I'll wait for Photos but it's actually too bad ...


'iPhoto to disk' app exports correctly albums and pictures in each album in a tree hierarchy... ( so i guess they did reverse engineering...)

in my script I also want to do it, adding an important functionality for my customer : synchronising it with an AWS S3 bucket used by a web app...


simply said, I'll need a 'script' to synchronise an iPhoto ( or coming Photos) with an AWS S3 bucket ... as it's seem to be done for Flickr... to avoid end-user transfer tasks...


thanks for your feedback

Mar 23, 2015 12:34 PM in response to kadoudal

Hi,


Here is the sqlite command to get the modelid of the albums (the folderUuid of the folder is 0hSjVxyQT4CYtRr5GMDhQQ as example):

select modelid from RKAlbum where folderUuid = "0hSjVxyQT4CYtRr5GMDhQQ" and albumSubclass = 3;



Here is the sqlite command to get the name of the photos in an album (17 is a modelid of the album as example) :

select RKAlbumVersion.name from RKMaster, RKVersion, RKAlbumVersion where RKAlbumVersion.albumId = 17 and RKMaster.modelId = RKVersion.masterId and RKVersion.modelId = RKAlbumVersion.versionId;



I do not know enough ruby, but here's an example of a bash script :

#!//bin/bash
myfolderUuid="0hSjVxyQT4CYtRr5GMDhQQ" ## a folderUuid in the RKFolder table
sqlite3  ~/'Pictures/iPhoto Library.photolibrary/Database/apdb/Library.apdb' 'select modelid, name from RKAlbum where folderUuid = "'$myfolderUuid'"  and albumSubclass = 3;' | while read line; do
    echo "Album name = "${line##*|} ## print the name of this album
    ## print photo's name of this album
    sqlite3  ~/'Pictures/iPhoto Library.photolibrary/Database/apdb/Library.apdb' 'select RKVersion.name from RKMaster, RKVersion, RKAlbumVersion where RKAlbumVersion.albumId = '${line%%|*}' and RKMaster.modelId = RKVersion.masterId and RKVersion.modelId = RKAlbumVersion.versionId;'
    echo ""  ## print blank line
done

Mar 31, 2015 8:47 AM in response to Jacques Rioux

Hi Jacques


Thanks again for you feedback on iPhoto , it was helpful .. I can transfer selected pictures to an AWS S3 bucket as a webapp assets server.

I just discover that the Thumbnails directory is not as simple as I thought ...

I cannot use the image path/name to access the thumbnails

image => Master/2015/03/17/20150317-183414/DCP_2182.JPG

thumbnails =>

Thumbnails/2015/03/17/20150317-183414/6DxHFFV7QimjgrXfd%MVbQ/DCP_2182.JPG

Thumbnails/2015/03/17/20150317-183414/6DxHFFV7QimjgrXfd%MVbQ/DCP_2182_1024.JPG

there is an intermediate folder with encrypted/generated label .... so I cannot easily access both thumbnails ( medium & small sizes)


is there a n sqlite exec I can use to get them or any other trick..

thanks for feedback


kadoudal from Breizh

Apr 1, 2015 11:21 AM in response to kadoudal

Hi Kadoudal,


The thumbnail's path is in the "ImageProxies.apdb" database.


To get the thumbnail's path :

You need the RKVersion.modelid of the photo from RKMaster in Library.apdb

Here is the sqlite command to get the thumbnail's path from RKImageProxyState in "ImageProxies.apdb" (23 is a modelid of the photo as example)

select thumbnailPath, miniThumbnailPath from RKImageProxyState where versionid = 23;



Here's an example of a bash script (to print thumbnail's path)

#!//bin/bash  
myfolderUuid="0hSjVxyQT4CYtRr5GMDhQQ" ## a folderUuid in the RKFolder table (Library.apdb)  
iPhotoLib=$HOME"/Pictures/iPhoto Library.photolibrary/" ## the path of the iPhoto package
sqlite3  "$iPhotoLib""Database/apdb/Library.apdb" 'select modelid from RKAlbum where folderUuid = "'$myfolderUuid'"  and albumSubclass = 3;' | while read modID; do  
    ## get the RKVersion.modelid of every photo of this album  
    sqlite3  "$iPhotoLib""Database/apdb/Library.apdb" 'select RKVersion.modelid from RKMaster, RKVersion, RKAlbumVersion where RKAlbumVersion.albumId = '$modID' and RKMaster.modelId = RKVersion.masterId and RKVersion.modelId = RKAlbumVersion.versionId;'  | while read thisID; do
          ## get the thumbnail's path  in ImageProxies.apdb, the sed command add the path of the "Thumbnails" folder to every line of the output to get the full path
          sqlite3 -separator  "$iPhotoLib""Database/apdb/ImageProxies.apdb"  'select thumbnailPath, miniThumbnailPath from RKImageProxyState where versionid = '$thisID';' | sed -e s:^:"$iPhotoLib"Thumbnails/:
    done
done

Jun 11, 2016 4:58 PM in response to chriscozi

Hello chriscozi,

In fact, the OP never got the correct answer at all. The correct answer is "don't even try it". Attempting to access some other company's internal, unpublished data structures is doomed to fail. At best, you would have to test and release an update to your software every time that other company (Apple in this case), released an update.

Jun 11, 2016 5:39 PM in response to etresoft

Wow, I am having great difficulty believing you.

I'll try not to make this a 'flame' post.

In less than thirty seconds I thought of multiple software apps over multiple DECADES of updates that do/did exactly that.

These were/are successful companies.

Because these are 'unpublished' data structures I can understand your assumption that any software based on them is 'doomed to fail'.

Please don't spread FUD.

Apple is successful. Photos is used by many people. Some of those people are software engineers. Any one of them can accomplish a great deal with the unpublished data structures at the heart of Apple Photos software.

Thank you for your response.

Jun 11, 2016 9:08 PM in response to chriscozi

Hello again chriscozi.

The world of software isn't like it was decades ago. Apple can, and will, make significant changes in its operating system in a matter of days. You don't have to believe me. You are more than welcome to try to reverse engineer something Apple has built and then release your own software that uses it. You won't release it in Apple's App Stores, because that is strictly disallowed. You can release it on your own, and maybe you will get lucky once or twice. But ultimately, you are just going to be disappointing and frustrating your users.


You are just one person. You do not have the ability to reverse engineer Apple's software faster than Apple changes it. Even if you are trying to release software based on public interfaces that are supposed to be available for 3rd party developers, just staying ahead of Apple's changes and bug production rate is a significant challenge.


My suggestion is to pick another project.

where can I find information on iPhoto Library SQLite schema , i.e. major tables relationships

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.