Download original pictures from the picasaweb

Even the google picasaweb API support up to 1600×1200, we can grab the original pictures by changing the URL of the picture.

20th line is the highlight. I found this hack after googling, but I forgot the URL. -_-

First you should have python and install the Google Data Library

Don’t forget to change the USER_ID and USER_PASSWORD with yours.

#!/usr/bin/env python

import gdata.photos.service
import gdata.media
import gdata.geo
import urllib
import os
import sys

URL_TO_GET_PHOTOS 	= '/data/feed/api/user/default/albumid/%s?kind=photo'
URL_TO_GET_TAGS 	= '/data/feed/api/user/default/albumid/%s/photoid/%s?kind=tag' 
URL_TO_GET_COMMENTS	= '/data/feed/api/user/default/albumid/%s/photoid/%s?kind=comment'

# Change the followings with yours
USER_ID				= 'YOUR_GMAIL_ID'
USER_PASSWORD		= 'YOUR_GMAIL_PASSWORD'


def download_file( url, dir_name ):
	"Download the data at URL to the current directory"
	basename = url[url.rindex('/') + 1:] # figure out a good name for the downloaded file.
	url = url.replace(basename, "d/"+basename)

	urllib.urlretrieve(url, dir_name+"/"+basename)

def connect_to_picasa( name, password ):
	gd_client = gdata.photos.service.PhotosService()
	gd_client.email = USER_ID
	gd_client.password = USER_PASSWORD
	gd_client.source = 'api-sample-google-com'
	gd_client.ProgrammaticLogin()

	return gd_client

def get_album_list( gd_client ):
	return gd_client.GetUserFeed()

def print_photo_list( albums ):
	for album in albums.entry:
		downloaded_photos = 0
		print 'Album: %s (%s)' % (album.title.text, album.numphotos.text)

		if not os.path.exists(album.title.text) :
			os.mkdir(album.title.text)

		photos = gd_client.GetFeed(URL_TO_GET_PHOTOS % (album.gphoto_id.text))

		for photo in photos.entry:
			download_file( photo.content.src, album.title.text )
			downloaded_photos += 1

			sys.stdout.write("\t%d/%s  %.1f %%\r" %(downloaded_photos, album.numphotos.text, 100.0*downloaded_photos/eval(album.numphotos.text)))
			sys.stdout.flush()

		print ""
		

if __name__ == '__main__':
	gd_client = connect_to_picasa( USER_ID, USER_PASSWORD )
	albums = get_album_list( gd_client )
	print_photo_list( albums )
	

11 thoughts on “Download original pictures from the picasaweb

  1. Hello Cychong,

    thanks for your comment on my blog. Unfortunately I have not published it because in my post I write specifically about getting original photos from Picasaweb without having to install any scripts or additional software. The intention behind this is to make it as easy as possible for all level experience users to get the original photos and I am not sure if noobs will understand Python or your script.

    I must say though that your script looks intriguing and I will give it a try. Thanks so much! If you check online you will find many more Python and other scripts to get the original photos and perhaps it would be better to post a comment on posts specifically talking about scripts to download the original photos.

    I hope you do understand my point here are don’t hold it against me. Your blog is really interesting and I have bookmarked it, the design/theme you picked is also very neat and tidy compared to my still quite messy theme. I am working on a minimal blogger theme at the moment. It would be great to hear back from you.

    All the best!
    Telux

    1. Hi,

      I understand your intention – not install anything at all. I use Mac OS X. Therefore I think installing only the gdata is pretty trivial(I have used *nix for more than 10 years. So I think everyone is good at using *nix -_-).

      One more thing, I try to find to get the script which download the original pictures. But I can not. All the script I found just getting up to 1600×1200.

      Anyway thanks for the comment. 🙂

  2. Dear Cychong,

    I have given this some thought and have a proposition for you.

    First of all why is it not possible to download the photos without giving one’s personal USER_ID and USER_PASSWORD? I am sure there is lots of people that either do not want to give their details or otherwise don’t have a Google/Picasaweb account at all. Can you fix that?

    Then I would like to ask you if you could include the option in your script to not only download all the original photos from one album but also give the user the option to download all the albums from a particular Picasaweb user in original size?

    Ideally it would be great if you could write it so that the user is being asked to what drive and what directory the albums and photos are being saved and then download the albums and save them with the original album names.

    Additionally if you can make the album option so that the user can select what albums from an account she/he wants to download, instead of only having the option to download them all that would be great.

    If you manage to include these options in your script I am more than happy to write up a detailed tutorial on how to install Python, the Google Data Library and last not least your script. Of course I will mention your site and credit your work and together we can help users getting albums and photos from Picasaweb in original full size.

    Are you in? Does something like that interest you? I think it would be great and with a detailed tutorial I think also inexperienced users would sure give it a try.

    Most important like this Mac users that do not like to install Firefox and DownThemAll! can use such a method as well and so benefit as well.

    Thanks so much for your reply, hope to hear from you soon.

    Regards,
    Telux

    1. Hi, Thanks for the suggestion.
      I add my answer in your comments. Please see the comments.

      Dear Cychong,

      I have given this some thought and have a proposition for you.

      First of all why is it not possible to download the photos without giving one’s personal USER_ID and USER_PASSWORD? I am sure there is lots of people that either do not want to give their details or otherwise don’t have a Google/Picasaweb account at all. Can you fix that?
      >> The ID and password is required to access photo of ‘ID’
      >> Basically the picasaweb API is intended to access galler of ‘ID’ and it need the login procedure definitely.

      Then I would like to ask you if you could include the option in your script to not only download all the original photos from one album but also give the user the option to download all the albums from a particular Picasaweb user in original size?
      >> I think the above answer applies here too.

      Ideally it would be great if you could write it so that the user is being asked to what drive and what directory the albums and photos are being saved and then download the albums and save them with the original album names.
      >> It is not difficult to add this feature. Just prompt to get the destination.

      Additionally if you can make the album option so that the user can select what albums from an account she/he wants to download, instead of only having the option to download them all that would be great.

      If you manage to include these options in your script I am more than happy to write up a detailed tutorial on how to install Python, the Google Data Library and last not least your script. Of course I will mention your site and credit your work and together we can help users getting albums and photos from Picasaweb in original full size.

      Are you in? Does something like that interest you? I think it would be great and with a detailed tutorial I think also inexperienced users would sure give it a try.
      >> I think your suggestion is about the UI. In CLI software(such as script I posted), we can list all the albums and get the albums from the user. However, the user should type the album name or something else(such as index number assigned to each album by script). It works but it is pretty awkward I think. To provide that kinds of feature, we should think about the GUI.(Actually there are several GUI which use the pyGTK library)

      Most important like this Mac users that do not like to install Firefox and DownThemAll! can use such a method as well and so benefit as well.

      Thanks so much for your reply, hope to hear from you soon.

      Regards,
      Telux

  3. Here check this site: http://picasawebutility.appspot.com/ and in the username field type “cichamaryjka5” for example.

    You will see a page with all the albums listed. Without giving a username and password. So it must be possible to acquire a list of all the albums a user has.

    Subsequently it must also be possible to get all original photos from all albums from a user without signing into Picasaweb with a username and password. Of course only the public albums will be displayed!

    So what we need is a GUI where people can type in the username and a list of all public albums will appear. On the above appspot example page not the original photos are downloaded as expected, they are limited to 1200x1600pix.

    Then in that list people can select what albums to download or “select all albums” and download. Then a promt is given to where they should be stored on the drive. Then they will be stored there with subfolders of the album names automatically being generated. All photos will be saved in original size.

    Do you think you can do that? I have given you an email address in the comment form where you can contact me directly. Email me and we can discuss this further. And yes having something like this for Mac users would be great! I have seen similar software but it does not work well and often does not download all photos and of course not in original size and most of all not for the Mac platform.

    Speak soon!

  4. Fantastic script, worked brilliantly for downloading ALL images with original names and album names, where all else failed. Thank you so much!

Leave a comment