неделя, 26 август 2007 г.

Upload digiKam photos to Picasa Web Albums

Introduction
This simple python script allows batch uploading of photos from digiKam photo organizer to Picasa Web Albums service. The idea is pretty simple - tag the photos inside digiKam with specific tag (e.g. "web") and then run a script that creates new album in your Picasa Web account and uploads the tagged photos automatically. The script also resizes the images to a resolution suitable for viewing on a screen (1280x1024) to save space and speed up the upload. It utilizes the gdata-python-client API from Google to upload the photos, Python Imaging Library (PIL) for resizing and pysqlite for accessing the digiKam database. The script also supports uploading files from the file system

How to install

  • Make sure you have Python and required library packages. If you are running Ubuntu Linux it is easy as:
    $ sudo apt-get install python python-imaging python-pysqlite2 jhead
    The last package (jhead) is required to copy metadata from original images to resized ones. It is optional (but highly recommended) to install
  • Download the gdata-python-client library tar ball. 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
  • Download and save digikam_picasa.py script.
  • That's it - lets use the script!

Usage

Lets try to upload few images from file system first. All you need to do is to specify the credentials for accessing the service (username, password), the album name and the files:

$ python digikam_picasa.py -u joe.user@gmail.com -p secret -a NewAlbum -f IMG_0001.JPG

This command will upload the image IMG_0001.JPG from the current directory into a new album called NewAlbum.
Now, lets upload the photos tagged with "web" in the digikam. You need to specify the the digikam's database file - digikam3.db. It is located in the root of directory digiKam uses to store the images (Settings > Configure > Albums > Album Library Path):

$ python digikam_picasa.py -u joe.user@gmail.com -p secret -a NewAlbum -t web -d /media/data/photos/digikam3.db

This command will upload all photos tagged with "web" in the digiKam. If you want to upload images with different tag, just change the -t parameter.
If you want to change the default image size (1280x1024) you can change the width and height parameters in the script's source.

Acknowledgements

This script is heavily derived from the script written by Marcin Sochacki and Ulrik Stervbo. On this page you can find alternative projects for automating the upload to Picasa Web Service

6 коментара:

overflow каза...

very good script. Congratulations

Unknown каза...

Thanks

Unknown каза...

Nice script!
What about using regular expressions in script? For example, if I want to use it without adding any tags in digikam, just want to upload all the files from current directory?

Tried do use "-f *.JPG", it didn't work.

Unknown каза...

Ooops, my fault. Regular expressions work :)

Свилен Иванов каза...

Артём, yes - it relies on shell expansion in order to work - don't put quotes around *.JPG.

Анонимен каза...

It is fun to have Web Album in your own site. It's a creative way of storing your photos.