Download Entire Google+ or Picasa Albums

A few weeks ago I stumbled across some really nice albums on Google+. There was even an anti-watermark movement that promoted users to upload beautiful, high-resolution, watermark-free photographs to the social network. One album in particular caught my attention, enough so that I wanted to use photos in the album as wallpapers for my desktop. The following is the journey through the wonderful world of Google I embarked on to obtain these wonderful images.

Where do we Start?

Get album URL

Let's get something straight. All photo albums on Google+ are in fact Picasa Web albums. Look at the image above. There are two long strings of numbers separated by /albums/. The first string is the user ID while the second string is the album ID.

I'll save you the trouble of finding the album on Picasa as the link is useless. Usually you can use Picasa Web to download entire albums using the Picasa desktop client. For some reason, most likely the album's size, Picasa Web won't pass over the RSS feed that Picasa Desktop needs to download the album. Rest assured, we're going to get the XML containing the album's photos using the Picasa Web Albums Data API.

Tax the API

https://picasaweb.google.com/data/feed/api/user/userID/albumid/albumID?imgmax=d

Replace userID and albumID in the API call with the two strings found in the Google+ album above. By placing ?imgmax=d at the end of the request the API will return the original uploaded image. The XML file produced is quite large, well over 3MB.

The Rest is Server-Side

The next steps assume you have access to a server, or a local desktop that can run code written in PHP and a bunch of disk space available. Create the following setup on your PHP-capable machine.

Get album files

put is the directory PHP will save the images to, photos.xml is the XML file containing all the image information. Open up download.php and write the following code.

<?

$xml = simplexml_load_file("photos.xml");

foreach($xml->entry as $child) {
    $children = $child->children();

    //get the url
    $url = $children->content['src'];

    //get the title
    $title = $children->title;

    //save the image
    echo "Saving: " . $title . "<br />";
    file_put_contents("put/$title", file_get_contents($url));
    echo "Saved!<br /><br />";
}

?>

Execution

Yup, you'll be killing your machine's connection for a while since quite a bit of data is about to be transferred. If you're on a shared host, please be mindful and do this on off-peak times so you don't negatively affect other users. Navigate to download.php in your browser and watch the verbose output. If possible, run this using PHP's command line interface because it will go past PHP's default 30 seconds of script execution time.

Wrapping Up

It takes forever, I know, but there are times when this is the only way to get all the original photos in an album. Once everything is finished downloading, grab the images from the put directory and go H.A.M.

Get album finished

Special thanks to Trey Ratcliff for not only taking the beautiful pictures used in this tutorial, but for also making them available on Google+ without watermarks whatsoever.