Saturday, February 4, 2012

Searching EXIF data with Mac OS X Spotlight

Using Mac OS X Spotlight, you can quickly search for certain camera metadata. A simple search would be "D300" (without quotation marks) entered in the field you get when you click on the magnifying glass in the upper right corner of your screen. That returns all images, both NEF and JPEG, that were taken with a Nikon D300 camera. By default you also get all other files that contain D300, like PDF files, word documents and old mails where you discussed the camera with friends. To limit the search to just images, go to "Show all in Finder". That will open a window with the title "Searching this Mac". Here you can click on a plus ⊕ symbol to get more search criteria. Click on it and select "Kind" as "Image", and you will only get image files.


If you instead of selecting Kind, select "Other", you get a vast number of search criteria to choose from, like ISO or EXIF version.

To really see all the criteria you can search from, you can use a Terminal window.
  1. Open the Terminal from Applications > Utilities > Terminal.
  2. Type "mdls " without quotation marks, but with the space after the last "s".
  3. Go to the Finder and drag an image file onto the Terminal window. It should now contain text that looks something like "$ mdls /Users/myhome/Desktop/mypic.jpg"
  4. Type "| less" after the file name and hit Enter.
What you now get is a list of searchable fields for the image, and their values:

kMDItemAcquisitionMake         = "NIKON CORPORATION"
kMDItemAcquisitionModel        = "NIKON D300"
kMDItemAlternateNames          = (
    "mypic.jpg"
)
kMDItemBitsPerSample           = 32
kMDItemColorSpace              = "RGB"
kMDItemExposureTimeSeconds     = 0.004
...

To move down to see more options, hit the Space Bar.
To move back up, type "B".
To leave the list, type "Q".

Now we can go back to Spotlight to use this information for an actual search.
  1. Click on plus ⊕ again, and select "Other".
  2. Select "Raw Query".
  3. In the search field, type a field name from the Terminal and some appropriate value, like "kMDItemExposureTimeSeconds < 0.003"
This will display all photos with a kMDItemExposureTimeSeconds (shutter speed) that is faster than 0.003 seconds.


If you know you want to repeat the same query over and over, you can hit the "Save" button, and you will get a virtual folder for quick access, whenever you need it.

Everything that is written here actually applies to all kinds of files, not only images, but as this is a photo blog, all the examples come from the wonderful world of images.

Searching in Adobe Bridge

If you want to find all photos you ever took with, say ISO 200, you can easily do that in Adobe Bridge. You just select Edit > Find, select "ISO" as search criteria and "200" as value.

It is slightly more tricky if you want to search for all files with a particular shutter speed or aperture, as these fields do not appear as search criteria. What you can do is to search for Exposure, which is a field that contains both those values. E.g.: "1/30 s at f/2.8". This means that you have to enter the values as free form text.
Some fields, like ISO and Focal length, are numeric, so you can search for all photos where the Focal length is greater than 50mm. However, the Exposure field is a text field, so it is very difficult to collect all files with shutterspeed greater than 1/200.