Manipulating the Mac Photos Library

If you're not a technically-inclined user of the Apple Photos app, you may want to skip this one!
The master copies of my photos live in two different worlds.
There are the quick snaps taken on my iPhone: handy to browse, to share, to sync across devices and, increasingly important for me, to search by using a map. I generally access these, like everyone else, using the Apple Photos app, and they're backed up to iCloud.
Then there are the 'proper' photos: taken on a 'real' camera, stored on a ZFS filesystem on my NAS, backed up automatically to two remote locations, and managed using Photo Mechanic and Capture One.
But increasingly, of course, the boundary between these is blurring, as phone cameras become capable of taking serious pictures, and as modern-day tasks such as sharing on social media and sending using Airdrop become something I want to do with my 'proper' photos too.
So I've started to experiment with ways to blend the two, and will talk more about them in a later post if they work well! But in the meantime, I just wanted to introduce Rhet Turnbull's excellent osxphotos software, which is really handy for anyone wanting to do something similar.
It's a command-line tool (and Python module) that can provide access to the Photos library and gives you a wide range of options. Here's just one example as an illustration:
osxphotos export ~/PhotoSync/FromPhotos \
--favorite --update --sidecar XMP \
--download-missing --exiftool \
--skip-edited
This will export any photos marked as 'Favourites' to the ~/PhotoSync/FromPhotos directory, only if they're new or updated since a previous export. It will create an XMP sidecar file -- a standard XML format for storing metadata alongside the images -- for each one. If the file is on iCloud but not on your local device, it will attempt to download it first, and it will skip versions edited in Photos because I just want the raw originals for my particular workflow. (There is a vast array of further options available, just on the export command! If, say, the Photos app has recognised the faces in your photos, you can turn the names into keywords in your exported files.)
And hey presto, I have a nice directory of favourite iPhone photos to incorporate in the library of my 'proper' photo-management software.
The import and export subcommands are the key ones for most people, but there are a couple of dozen other options...for example:
osxphotos labelswill print out all the automatically-assigned labels given to your photos; I was interested to find things like 'floodplain' and 'handwriting' in there; terms I wouldn't otherwise have thought of typing into the search box.osxphotos add-locationswill let you find photos that have no location info and assign them a location if found on another photo taken within a specified time period: handy if, say, you took a photo with your good camera (which has no GPS) and would like to copy the geotags from the snaps you took at the same time with your iPhone.- Some of the commands, though entered on the command line, will operate by default on any images you've currently got selected in the Photos app. I've just clicked a couple of pictures of Rose and Tilly, and set their captions using:
osxphotos batch-edit --caption "Rose and Tilly {created.year}-{created.mm}-{created.dd}"
Anyway, I hope this gives you some ideas. I'll be playing with this a lot in future, I think!
Leave a Comment