View Full Version : Lightroom Catalog Table Structure

05-30-2010, 03:42 PM
Some of you know that I am an old gray-beard programmer from a prior life. Well I decided to build an application for my own in-house use that reads information from a Lightroom Catalog. Doubt that it will ever be a commercially viable app but then you never know.

I need to read information from the LR catalog (actually, a copy of the catalog) which is actually a SQLite RDBMS. I can find all the information I am looking for in the various cryptic tables in the database. Problem is I can't figure out how to tie the rows in the various tables together for a particular image. Most tables contain fields for id_local and id_global but they don't match across tables.
I thought it would be obvious how the tables were structured by creating a catalog with only 3 images in it with very clear caption and title information in each. This is how I know that what I thought would be the primary keys (tied to a particular image) don't contain the same values.
Does anyone know how the tables are structured, or where they are documented or who I can contact for more information?
bill plunkett

06-06-2010, 03:03 PM
Are you looking for a way to read out the metadata of the images? I've had good success reading the metadata out with PHP using the GD Image Library resizing function. This doesn't take the library as the input, but rather strips the metadata from the actual files - maybe this would be an option? I use in my website's internal programming to resize images and load metadata into searchable MySQL tables used in the programming of the site.

Let me know if you need help in figuring this.


Raymond Klass Photography and Workshops (www.klassphoto.com)

06-20-2010, 06:56 PM
Hi Ray,

thanks for reply. I have got my method worked out now. I really didn't what to have to navigate through all image files in my folders. I have a SQLite database for images that are either at my stock agent or that I sell prints of. These images are all identified with an ImageID number that has been included in a custom metadata field in the LR Catalog. That way I can use my SQL app and access only the image records in the LR catalog that have an ImageID. After some time spent "hacking" the catalog structure I've got it all sorted out. Unfortunately, the only way to get to a couple of the fields like Title and Caption is to parse the XMP data stored in one of the tables. This would be the same data you are accessing by reading the metadata from the image file itself. LR stores a copy of the XMP in a field in the SQL table. The parsing is a little messy but it does get to all the data I need in my application, being prototyped in REALBasic but will actually be written in XCODE (Objective-C)

see you later Ray,