Syncing Google and Gravatar profile photos to Nextcloud contacts

When I decided to migrate my life from Google to my own, private server
, one of the first things I moved was my contacts. I exported my contact list from Gmail and import it into Nextcloud.

Seems easy enough! Well, despite a few hiccups resulting from some unsupported or poorly escaped links, I was up and running in short order. I could now see my contacts in Nextcloud and they were syncing to my phone and computer perfectly.

It was probably that day when I received a text from my wife and saw the icon was just her initials! To my dismay, when I dug in further I found that Google does not export contacts photos along with your contacts!

Modern applications all support and, in some cases, expect contacts to have some kind of photo. Phone calls display faces, in a crowded messaging app, the little faces make it easy to make sure you’re writing the right person. It also just makes otherwise bland digital communication just a little bit more personal.

Contact photo displayed for incoming calls

When I finally decided to do something about it, I began exploring the Google APIs and found that their People API provides a way to retrieve the URL of a contacts photo. A full migration could actually be possible!

With the Python libraries that Google provides to get the URLs, vdirsyncer to sync with Nextcloud, vobject for parsing and editing contact, and a few hours of free time I was able to sync a few hundred profile photos from Google to my Nextcloud server!

There were a couple users that I figured probably had some kind of profile photo, but maybe not Google, so I added a check for Gravatar as a fallback as well and got... two more photos. Maybe someone else will have more luck!

If you’re in a similar boat, check out the repo (Github mirror) and usage instructions. Happy to take feedback through GitHub issues.