Gallery command line uploader

I use Gallery to manage my photo albums. Back when I used Windows, I used Gallery Remote to upload images to Gallery. Update: I no longer use Gallery to manage my photos.

My workflow generally went like this:

  1. Sift through hundreds of photos
  2. Pick the ones that together help convey a visual story
  3. Jot each photo number down in a text file and write a brief caption next to it (steps 1-3 might collectively take several days, hence the benefit of storing the list in progress as a text file)
  4. Open up the folder containing the photos and position it next to Gallery Remote and above my text file
  5. Drag each photo marked in the text file into Gallery Remote, doing about 10 at a time (Gallery Remote had a tendency to crash, so I tried to eliminate the risk by only going through the trouble of selecting 10 or so at a time)
  6. Upload, and repeat until done
  7. Enter captions for all of the images in the Gallery web interface by copying each individual caption from the text file and pasting it under the appropriate thumbnail in the web interface

Pretty time-consuming (which probably explains why I didn’t upload many photos), but it got the job done.

Recently I created my text file for the first of several France trip albums. Update: I split up my Paris photo gallery among several blog posts, primarily Notre Dame sans bossu and La Tour Eiffel. It contained 42 photo IDs and their captions. But having moved to Ubuntu, I lost the ability to use Gallery Remote (it doesn’t install, and doesn’t seem to be packaged for Debian or Ubuntu). I took a look at Gallery’s text field uploading web interface, and about choked. NFW was I going through that.

So last week, I greased my rusty Perl muscles, supported heavily by my PHP muscles, and wrote a simple uploader script that would eliminate all this drag-and-drop, cut-and-paste nonsense. It just reads from my text file (which makes a whole lotta sense to me, so why shouldn’t it to a computer) and uploads the photos to Gallery.

It took some research, some prior art analysis, and even some print statements in GalleryRemote.inc, but eventually I came up with something that works. For me. And maybe you.

Prerequisites

Gallery 2 (tested on 2.1.2 and 2.2.1)
Perl 5
Term::ReadKey

sudo aptitude install libterm-readkey-perl

Installation

Download gallery-uploader.zip

unzip gallery-uploader.zip

Usage

gallery-uploader -l username -u url -a albumurl -f textfile

Where…

  • username is your gallery user name
  • url is the full URL to your Gallery2 install, including main.php
  • albumurl is the unique identifier that becomes part of the album url
  • textfile is the path to the file containing the list of photos in the format specified below

After hitting enter, you’ll be prompted for your password.

e.g.

gallery-uploader -l admin -u http://example.com/gallery/main.php -a spring_break -f photos.txt

Note: before using the script, make sure the album referred to by albumurl has already been created through the web interface.

Text-file format

One photo to upload per line, consisting of the path (absolute, relative, or partial) to the image (without spaces), a space, and a caption to the end of the line. e.g.

/home/justin/photos/france_trip/IMG_0666.JPG This is St. Sulpice

If you run the gallery-uploader script from within the directory containing the photos (e.g. /home/justin/photos/france_trip), you can omit the absolute path. This is especially useful if it contains spaces.

IMG_0666.JPG This is St. Sulpice

To make things even easier, since the unique part of the photo is really only 0666, you can use that alone to refer to the photo, and the script will look for a single file containing that identifier (in the directory where the gallery-uploader is run).

0666 This is St. Sulpice

Note: blank lines and lines beginning with # are ignored.

Todo

If the album doesn’t exist, prompt user and offer to create it. There doesn’t seem to be a way to check for the existence of an album via the API.

comments: 1 so far...

name
blog (optional)
comment

Hi!

Thats interesting, though Gallery Remote should work fine on Debian/Ubuntu after all it’s just a Java Application.

There is also a command line (perl) based uploader available already.

That being said, feel free to add your uploader to the “other clients” section on the documentation site.

monthchunks

license

Justinsomnia is licensed under a Creative Commons Attribution 3.0 License.

Please see my Attribution Policy for more information.