Five start JPG syncer to Google Photo

by: Marcel-Jan, 6 years ago

Last edited: 6 years ago

I'm having a good time following the tutorials on this site. I thought it would be interesting to share what Python program I'm working on currently.

When I just followed to Python courses on Coursera I thought it would be a good idea to try to automate something at home, to learn from. But I couldn't come up with anything. Until I was busy organizing my photos from a recent holiday and I shot a lot of photo's. Some people I traveled with asked me to put more photos online. Now I have 1000+ photos to go through. And I usually rate them in Adobe Bridge, and then edit the best ones and upload them manually to a Google Photo album. That last step was such a hassle: finding out which newly rated photos are to be uploaded.

So I wanted a Python program to compare jpgs with a rating of 4 or 5 stars in a directory on my computer to jpgs already at Google Photo.

The first step was selecting all 4 or 5 star jpgs in a directory. That proved to be more difficult than I thought. Weird things happened when I tried to prepare test-jpgs with ratings and changed them in Windows Explorer. Turns out: there is not just one place in jpg metadata where ratings are stored. Adobe Bridge's ratings are stored in something called XMP metadata. Windows Explorer can read that, but when you change the rating there, they get stored somewhere else. All in the same jpg file, people.

Eventually I got the advice to use the exiftool (https://sno.phy.queensu.ca/~phil/exiftool/). Rename the executable to exiftool.exe. Make sure the exifinfo.exe executable somewhere in Windows' path, so it Python can find it. There is a pyexifinfo library (pip install pyexifinfo) which uses the exifinfo executable to do your bidding.

And surely, after I while I managed to get a list of all jpgs with a rating of 4 or 5 as given in Adobe Bridge.

import os, sys, glob
import pyexifinfo as exif

# Open a file
path = r"D:filesPythonjpgsync_test"
# Pick only jpgs
filelist = glob.glob( path + "*.JPG" )

# This would print all the files and directories
for file in filelist:
   # Toon de file waar je mee bezig bent
   print file
  
   # Haal metadata op uit jpg
   metadata = exif.get_json(file)
  
   for met in metadata:
       # Indien er een key is met naam XMP:Rating, toon deze dan
       if 'XMP:Rating' in met.keys():
           print met["XMP:Rating"]



The next step is connecting to Google Photo. There used to be a Picasa API, I believe it's called Picker now. I haven't exactly understood the whole OAuth2 proces yet, but that's another step.

So that's where I'm working on. I hope you found it interesting. Tips for further progress are welcome of course.



You must be logged in to post. Please login or register an account.



Forgot to say: this is tested in Python 2.7. I'll make a Python 3 version of it shortly.

-Marcel-Jan 6 years ago

You must be logged in to post. Please login or register an account.


.. but pyexiftool is Python 2 only.

-Marcel-Jan 6 years ago

You must be logged in to post. Please login or register an account.

Hi, thanks. Very keen to know where you got to with this.

-Maxp 3 years ago

You must be logged in to post. Please login or register an account.