What catalog is that file in?

That's what I hear often from my wife Meg; a professional photographer. Meg uses Adobe Photoshop Lightroom for cataloging the pictures she takes for her business as well as the pictures she take of our family. An underlying frustration that I find with Lightroom is the fact that photos become lost inside different catalogs on your hard drive, and Lightroom lacks the ability to search across catalogs. Some photographers believe the answer is to have a few monolithic catalogs. While these catalogs may contain everything in one searchable database, the catalogs become slow and unwieldy in a few short gigs of data. My answer is to have many small catalogs and harness the great search capabilities within the Mac OS -- Spotlight. One small problem, Spotlight doesn't inherently know how to index a Lightroom .lrcat file. In order to overcome this shortcoming, I wrote my own Spotlight plugin; something called an importer (See the Spotlight Importer Programming Guide).

SQLite

Lightroom catalog files are actually SQLite databases and therefore extracting the necessary data was quite simple. I first used SQLite Manager in Firefox to examine the database. I came up with the following simple query to get at the filenames I would need to pass to Spotlight: The next step was to run this query from within Objective-C. After using the familiar OmniSQLite framework from the larger OmniGroup framework, I settled on a much smaller wrapper, FMDB.

Importer

It took several days before I wrapped my head around Spotlight and the necessary components of an importer. Probably the most difficult concept to understand was Uniform Type Identifiers (UTI). Adobe does not identify a UTI for their catalog files. I had to create my own in order for Spotlight to identify the files and know what importer to use in order to index Lightroom catalogs. I came up with com.adobe.lightroom.library. This UTI is in the Info.plist file of my importer under the Exported Type UTIs section.

Packaging

Take note that the package I created for installing the importer places the importer in ~/Library/Spotlight. I chose the user's home directory because I can install it without the need for a password. I also run this command after install. That causes Spotlight to index files already on disk. See here for more info.

Source Code

The codes speaks well for itself and that is why the source is open and hosted at Github. I also created a nice Github project page for the code. You can find the page here and the source code here.

Screenshot

Here is the importer in use: screenshot

Download

Download the installer package
  • Henrique Ribas

    Helo, it’s seems to be a fantastic “plugin”, but i could not make it work.
    Can you teach me?
    I’ve downloade te file you wrote, installed it, an then… should i search for an image filename or a keyword inside a catalog at the spotlight?
    It’s not working…
    Thanks.

    • davidbitton

      Henrique,
        Try and search for a known filename that exists in one of your catalogs by clicking the magnifying glass at the far right of the menu bar on your Mac. Take a look at the screenshot above. You’ll see the Spotlight icon (the magnifying glass) is highlighted at the end. That is where you perform the search. Spotlight will then inform you as to which catalog(s) has a filename matching your search. If this doesn’t work, please let me know. Thanks!

      • Henrique Ribas

        Hi David…
        Maybe i’m doing something very wrong.
        I thought it should work like you said. I did it for the first time after i installed and restarted my macbook pro. But it’s not working yet…

        Take a look…

        http://www.henriqueribas.com/screenshot/ss1.png

        • Henrique Ribas

          David, as you said at your main post…
          Was an index problem… everything is working now…

          GREAT JOB

          • Henrique Ribas

            I could only find by the name of the file…
            Is that possible to find by a keyword?

          • davidbitton

            Henrique,
            I only coded file name however I will look into adding keyword for a future release. Thanks for the suggestion.

          • Henrique Ribas

            Cool….

            let me know if you could add this feature… (contato@henriqueribas.com)
            Would be great.
            Thank you for your time… Great Job David…

      • Joao Leite

        David, about The sugestion made by Henrique, did you bot it?

        • Goulart Luc

          David, about the suggestion, could you make it?

          • @337a23d52a84361a50424c1b73528cfd:disqus and @5b5e4b7e6f267a40384e67f86a0f2286:disqus, I have implemented the requested addition, however for whatever reason, Spotlight wasn’t behaving on my machine so nothing was working. Let me see if I can get things moving. Thanks!

  • Great! I haven’t tried it yet, but this is precisely something that could be very usefull for me, and I will be giving it a shot as soon as I’m back to my studio.

    I can see why some people are interested in the keyword function, but definitely not a necessity for me.

    Thanks for this David!