Thoughts on technology and mathematics

Export Google Contacts to Roundcube, Including Photos

The fact that Google doesn’t export photos from Contacts didn’t bother me until very recently, when Roundcube announced support to display the contact picture along mails.

People have been complaining for years so it’s unlikely the situation will change anytime soon. Here are some workarounds.

Using an Android phone

If you have an android 4.x phone, this is definitely the easiest solution: Go to People, hit Menu, select Import/Export and finally Export to storage and you end up with a .vcs on your memory card that has all fields from the address book, including the photo.

Unfortunately, Roundcube 0.9 seems to have problems with the generated files - images don’t display and non-ascii characters are messed up. The following command is the result of a bit of trial-and-error and fixed it for me:

sed 's#^PHOTO;ENCODING=BASE64#PHOTO;ENCODING=b#' < orig.vcs > fixed.vcs

Using Thunderbird

Without an android phone, the only way to get those photos into roundcube seems via the Google Contacts plugin. It allows access to your Google Contacts from the Thunderbird address book and supports photos. Great, no? Well, almost. Thunderbird is still limited to two emails per contact. Depending how many users with >2 email entries you have this may bother you (the additional emails will simply be lost).

As there is no export in Thunderbird for vCard, you will also need ThunderSync. The plugin keeps your address book in sync with a folder of .vcs files.

Finally, apply the fix from above (while at the same time combining the generated files into one) and you’re done:

cat sync-folder/*.vcs |
  sed 's#^PHOTO;ENCODING=BASE64#PHOTO;ENCODING=b#' > fixed.vcs

If you have a better solution (automatic syncing comes to mind), please let me know in the comments.