Tag: Open Source

Manipulating the Mac Photos Library

Trees on Dunwich Heath

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 labels will 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-locations will 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!

Signalling virtue

Dear Reader,

Can I encourage you to try something today? Go to Signal.org and get hold of the Signal messaging app, and/or go to your app store and download Signal for your phone. And while it's downloading, come back here and I'll tell you why I've become so fond of it, and why you might actually want another messaging app.

To put it in a nutshell, Signal is like WhatsApp but without selling your soul. Imagine what a good time Faust would have had without that awkward business with the Devil, and you get the idea. Well, OK... you don't quite have to sell your soul to Facebook to use WhatsApp, but you do have give away your privacy, your friends' privacy, endure a lot of advertising, and so forth. (More info in an earlier post.)

For Apple users, Signal is rather like Messages, which I also like and use a lot, but you can use Signal with your non-Apple friends too, on all of your, and all of their, devices.

Signal:

  • is well-designed and nice to use.
  • runs on iOS, Android, Windows, Mac, Linux, tablets, desktop and mobile.
  • uses proper end-to-end encrypted communications, unlike some alternatives such as Telegram.
  • is Open Source, so if you doubt any aspect of it, you can go and see how it works.
  • is free: supported by grants and donations. No advertisements.
  • allows most of the interactions you expect on a modern messaging service: group chats, sharing files and images, audio and video chat, etc.

Now, of course, it has the problem that all networks initially have: what happens if none of my friends are on it? And yes, that can be an issue, but it's becoming less so. When I first signed up, I think I knew about three other users. Now, over 100 of my contacts are there, and more arrive every week. When I see them pop up, I send them a quick hello message just to welcome them and let them know I'm here too. It's a bit like wondering if you're at the wrong party because you know so few people here, and then over time more and more of your friends walk through the door.

How do you find them? Well, like WhatsApp, Signal works on phone numbers, and when you sign up you have the option to let it scan your contacts list and see if any of them are on Signal too. Unlike Facebook/WhatsApp, however, your contacts' details aren't transmitted to the company's servers and used to build the kind of personal profiles that FB keeps even on people who aren't members.

Signal instead encrypts (hashes) the phone numbers in your contacts, truncates the encrypted form so it can't be used to match the full phone number, sends those truncated versions to their servers, and if it finds matches for any truncated other account numbers it sends the encrypted possible matches back to you for your app to check. Security experts will realise that this isn't perfect either, but it's so much better than most of the alternatives that you can be much more comfortable doing it. Here's a page talking about it with a link to more detailed technical descriptions about how they're trying to make it even more secure. And here's the source code for all their software in case you don't trust what they say and want to check it out for yourself.

So in recent months, if I've wanted to set up group chat sessions to discuss the care of an elderly relative, or plan a boating holiday with friends, or discuss software development with colleagues in another timezone, I tell people that I disconnected from Facebook a few years back so I don't do WhatsApp, but have you tried Signal? It's pretty much the same, with all the bad bits taken out, and works much better on the desktop and on tablets, in my now-rather-dated experience, than WhatsApp ever did.

So give it a try, and if you find that not many friends are there, don't delete it. Just wait a bit... and tell all your friends about this post, of course!

Duplicate mail messages

In my various shufflings, copyings, archivings of email messages between my IMAP folders, I often end up with duplicates.

Sometimes, a copy or move goes badly wrong and I end up with hundreds of duplicates.

Many years ago I wrote a bit of Java code which would find and remove duplicates, but I've now converted it to a Python script and released it as Open Source, in case it's useful to anyone else.

You can find IMAPdedup here.

Feedback and improvements welcome!