Polska wersja

Marcin Sochacki (Wanted) Blog, Internet, Technology

» Uploading photos to Picasa Web Albums from Linux

Picasa Web Albums is one of many websites for hosting photos online and making web galleries. I for one like the site a lot; I'm not quite a fan of Flickr, for instance.

Up until quite recently, users of operating systems other than Windows or Mac OS X had a problem though – no tools were available for batch uploading. A couple of pictures are not a big deal, one can just upload them via web form, but if you have more than a dozen, clicking becomes very cumbersome. The Picasa client for Linux, available since June 2006 (works under WINE) does not support Picasa Web. Fortunately, Google following the tradition of open standards, recently published the API for Picasa Web Albums.

Update: 2007-06-25.

An open API makes it possible to write tools for any platform and programming language. The first known implementation for Linux was the GNOME picture viewer F-Spot. For those who like GUI apps and have nothing against Mono, F-Spot is probably the best choice at the moment.

I, on the other hand, was not keen to install F-Spot, because it would also pull a lot of dependencies:

Depends: libart-2.0-2 (>= 2.3.16), libatk1.0-0 (>= 1.13.1), libbonobo2-0 (>= 2.15.0), libbonoboui2-0 (>= 2.15.1), libc6 (>= 2.5-0ubuntu1), libcairo2 (>= 1.4.2), libexif12, libfontconfig1 (>= 2.4.0), libgconf2-4 (>= 2.13.5), libglib2.0-0 (>= 2.12.9), libgnome-keyring0 (>= 0.7.1), libgnome2-0 (>= 2.14.1), libgnomecanvas2-0 (>= 2.11.1), libgnomeui-0 (>= 2.17.1), libgnomevfs2-0 (>= 1:2.17.90), libgtk2.0-0 (>= 2.10.3), libice6 (>= 1:1.0.0), libjpeg62, liblcms1 (>= 1.08-1), libmono0 (>= 1.2.3), liborbit2 (>= 1:2.14.1), libpango1.0-0 (>= 1.16.1), libpopt0 (>= 1.10), libsm6, libx11-6, libxcursor1 (>> 1.1.2), libxext6, libxfixes3 (>= 1:4.0.1), libxi6, libxinerama1, libxrandr2 (>= 2:1.2.0), libxrender1, mono-runtime (>=, libc6 (>= 2.5-0ubuntu1) | libc6.1 (>= 2.5-0ubuntu1), libgconf2.0-cil (>= 2.15.0), libgl1-mesa-glx | libgl1, libglade2.0-cil (>= 2.9.0), libglib2.0-cil (>= 2.9.0), libgnome2.0-cil (>= 2.15.0), libgphoto2-2 (>= 2.3.0), libgphoto2-port0 (>= 2.3.0), libgtk2.0-cil (>= 2.9.0), libmono-corlib2.0-cil (>= 1.2.3), libmono-sharpzip2.84-cil (>= 1.0), libmono-sqlite2.0-cil (>= 1.0), libmono-system-data2.0-cil (>= 1.0), libmono-system-web2.0-cil (>= 1.0), libmono-system2.0-cil (>= 1.2.3), libmono2.0-cil (>= 1.2.3), libndesk-dbus-glib1.0-cil (>= 0.3), libndesk-dbus1.0-cil (>= 0.4)

I just didn't want to lose space for Mono environment, which would be used by this one and only program. Besides, .NET is evil :-)

I was looking for something small, working from command line. It turns out that several gdata API libraries are being developed in various languages, e.g. the Python implementation. Using this library we can quickly reach our target. But first, we need to write a simple script to use it, because the library as is doesn't contain user tools, but programmatic interfaces only.

I used a script by Jeff Scudder from Google as the base. It is included in the distribution as a unit test. I added a couple of lines to support command line parameters, made some cosmetic changes and here you are: picasa_upload.py. I'm not an expert in Python, so the script is not foolproof, but it should work.

Before you can use the script, you have install the gdata-python-client library. It has several dependencies: ElementTree, httplib, urllib modules. In Ubuntu all of them happen to be a part of standard python2.5 package, but in other distributions you might have to install additional packages. Next, unpack the gdata tarball and run:
./setup.py install --prefix=/usr/local

If all goes well, my script should now work correctly. Just change the variables username and password in the script accordingly and start testing. For example, here's how you can upload all JPEGs from the current directory to the album named “My_photos”.
$ ./picasa_upload.py My_photos *.jpg

Update (2007-06-25):
Ulrik Stervbo proposed some changes in the script, among others support for recursive file upload and better code structure. So I have replaced the version and you are welcome to download the new script again.

Additionally, some alternative projects appeared in the meantime. For the sake of completeness let me list all the tools, which help to manage your Google Picasa Web Albums from Linux (or other Unix-like operating systems, e.g. FreeBSD, Solaris, Mac OS X):

P.S. And Flickr sucks, because:

2007/06/25 21:44 | computers/linux/

» Comments

for file in sys.argv[2:]:
  print('Sending file %s' % file)
  ms.setFile(file, 'image/jpeg')
  media_entry = gd_client.Post(None,
  album_entry.GetFeedLink().href, media_source = ms)
  except gdata.service.RequestError:
  print('Failed sending %s' % file)

For some reason they didn't like one of my jpgs

Mikachu | 2007/05/27 03:57

OMG you're a genious! I've been searching for this for months! Thx

mcbuddha | 2007/05/28 13:24

great little commandline tool, thanks!

johnnycrash | 2007/05/29 11:43

Thank you.

san | 2007/05/31 00:00

Life Saver!  Thank you.

Gani Bhagavathula | 2007/06/10 18:01

Why does it create a new album?

Thanks in advance,

Mauro | 2007/06/15 01:15

I know this is a bit strange, but that's how Picasaweb API works -- it allows you to create a new album, even if you supply a name which already exists.

You can easily manage the photos online and organize them as you like; the main goal was to just get them there.

Wanted | 2007/06/15 23:11

Please check my project at: http://code.google.com/p/upload2picasa/

-- it's inspired by the script of yours, but allows to chose whether to create new album or to post to existing one (if the same name specified). Also it have some kind of `rights management': allows to state (only for the new albums) should it be listed in public gallery, or be private (by default).

logus | 2007/06/16 11:04

Nice tool! Thanks a Ton!
Keep hacking! :-)

Suresh | 2007/10/01 17:22

Thanks a Ton & Logus!

shadow21 | 2008/04/21 13:42

Now the same achieved with GoogleCl

g33k | 2010/06/20 09:03

My blog


/ (69)
  computers/ (40)
    apple/ (1)
    google/ (14)
    linux/ (3)
    microsoft/ (9)
    other/ (4)
    spam/ (1)
    wikipedia/ (3)
    www/ (5)
  i_like_it/ (15)
    film/ (6)
    fun/ (1)
    photo/ (2)
    sport/ (6)
  info/ (4)
  media/ (5)
    ad/ (5)
  places/ (5)
    aconcagua/ (1)
    dublin/ (2)
    tricity/ (2)



Color free zone

This site is Wit 2.0™ compliant!