Pages

Saturday, February 14, 2015

Downloading hi-resolution images from Google Photos using picasa web API in python

Out of 15 GB quota given by Google for combined usage of Gmail, Picasaweb (now Google Plus Photos) and Google drive I had used up almost 98% of them.

After cleaning up old and big emails which were not required  (searched "size:10m" in gmail) I figured out there still a lot of space taken by Google Photos. I have moved on to Flickr recently for my high resolution photos because Google counts any photos which is more than 2048 pixels (either height or width) towards their storage quota. The only photo being stored in Google photos now a days are the ones which are automatically backed up from my phone. Earlier I had set it up to back up the full resolutions photos hence I ended up running out of storage quota very quickly.

There is no straight forward way to filter Google Plus Photos by size and delete them. Also I wanted to download them before I permanently delete. I decided to do this programmatically as I did not find any tool online.

The below script basically scans a album (in my case the "Auto Backup" album ) for photos whose dimensions are more than 2048 and downloads them on the disk.

There are few points to be noted before you use this script.
  • Install Google Data python APIs from this site.
  • Keep increasing the "offset" variable if you think you have more than 1000 photos. This is because of the API limitation of being able to query only 1000 entries at a time.