Announce: galleryadd.pl 1.20

iainlea

Joined: 2004-09-24
Posts: 10
Posted: Thu, 2005-03-24 14:32

A perl script to add images or a recursive directory structure to a gallery.

I modified the galleryadd.pl script from Jesse Mullan (jmullan@visi.com)
and added a number of new features for ease of use.

You can download it here: http://iainlea.dyndns.org/software/galleryadd/

Usage: galleryadd.pl [options] [file(s) | dir(s)]
       -a album  album to be used for uploading image(s) or directory
       -c album  create new album for uploading image(s) or directory
       -d text   description for new album
       -g url    URL of gallery (default: http://gallery.yoursite.com)
       -l        list available albums for specified gallery
       -n        do not verify if album exists before starting upload
       -p pass   password to use to login to gallery
       -q        quiet mode (unless errors are encountered)
       -t text   title for new album (if not specified uses -A value)
       -u user   username to use to login to gallery (default: admin)
       -z        zap caption that is by default derived from filename
       -h        help
       -v        verbose

Examples:
  galleryadd.pl -g http://gallery -u admin -p mypass -a mycars bmw.jpg

    upload image bmw.jpg to album mycars

$GALLERY_[URL|USER|PASS|ALBUM|LOG] variables settable as defaults.

Changelog:

- changed -l option to output albums & subalbums in tree form

Here is an example run that creates a top level album and uploads a few
images:

$ galleryadd.pl -g gallery.mysite.com -u admin -p mypass -c 20050220 *.jpg

System  gallery.mysite.com
Login:  admin  [OK]
Create  20050220  [OK]
Album:  fetching list  [OK]
Album:  20050220  [OK]
Upload  race1.jpg  [687K] [355KB/s] [OK]
Upload  race2.jpg  [1.5M] [1.1MB/s] [OK]
Upload  race3.jpg  [ 98K] [340KB/s] [OK]

Enjoy. Feedback and any patches welcome.

Iain

 
antoinerose

Joined: 2005-06-06
Posts: 9
Posted: Mon, 2005-06-13 14:16

Hello guys,
While parsing the menalto.gallery remote forum, I saw your threads:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=27952

I'm trying to find a script/application that will automatically upload/synchronise on a regular basis images from a specific folder.
All the details might be found here:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=31546

Could you guys help me out ?
Thanks for your answer

If possible, plz reply to

or in the forum itself.
Antoine

 
gclowney

Joined: 2004-09-07
Posts: 8
Posted: Fri, 2005-06-24 06:21

Hello! I am pleased (and surprised) to see this post, and the large amount of work you've put into galleryadd.pl. These look like very good enhancements!

I have made my own enhancement to version 0.7a, and I would like you to consider folding it into your version. This new feature allows people to add photos to their Gallery along with captions and other information that they've entered into other image cataloguing software.

For years I've been cataloguing my photo collection in spreadsheets. I use a simple macro to export selected lines to very basic XML files that look like this:

<XML_ROOT>
    <XML_RECORD>
        <EXCEL_ROW>3723</EXCEL_ROW>
        <Roll>greg's digital 2005\2005_06_19 (Fremont Festival)</Roll>
        <Shot>1</Shot>
        <Filename>2005-06-19_12.07.41_IMG_0823.JPG</Filename>
        <Date>6/19/2005</Date>
        <Subjects>John Doe; Jane Roe</Subjects>
        <Scene>Fremont Festival 2005</Scene>
        <Title>Pass the aspirin, please!</Title>
        <Description>Thanks to The Spoon Man for the fake cutlery.</Description>
        <Combined_Caption>Pass the aspirin, please!
Thanks to The Spoon Man for the fake cutlery.
[2005-06-19_12.07.41_IMG_0823.JPG]</Combined_Caption>
        <Rating>3</Rating>
    </XML_RECORD>

When the new -xml option is specified on the command line, my galleryaddxml.pl reads all the XML records in the specified file, and using the normal command-line information like URL, album, password, etc. adds each photo to the album along with its hand-crafted caption.

I chose to use XML instead of comma-separated variables because some photo cataloging programs (such as ACDSee) can export their catalogs to XML, and it would be trivial to either convert them to the schema used by galleryaddxml.pl or to modify galleryaddxml.pl to take new schema. Of course, it would also be easy to support CSV files or other formats.

This feature could be further improved in the future, such as:

  • allowing the user to specify a simple mapping of fields in their XML to Gallery fields
  • supporting Gallery's Custom Fields (which is a topic I'm going to post in a separate thread)
  • automatically detecting XML files so we don't need to command-line option
  • specifying source directory on the command line, since that would not normally be found in the XML
  • allowing Gallery fields to be set with values built from one or more XML fields (e.g. "$caption=$Title\n$Description\n[$Filename];")

So, is this something you'd be interested in folding into your source?

Thanks,
Greg[/]

 
daetty

Joined: 2005-07-29
Posts: 1
Posted: Fri, 2005-07-29 21:41

Hi Greg

I'm interested in your approach to combine galleryadd(xml).pl with captions because I need to migrate tons of old html picture gallery's to Gallery 1.5. I do have informations about the pictures and the captions in CSV format (12345.jpg;caption text comes here...).

Any help or maybe your customized perl file would be appreciated a lot.

Thanks,
Stefan

 
gclowney

Joined: 2004-09-07
Posts: 8
Posted: Sat, 2005-07-30 18:30

Hi Stefan,

Here is my latest version of galleryadd, called galleryadd-1.45.pl, based on galleryadd.pl 1.40 as posted by Iain Lea. However, I see that Ian just posted on his web site a version 1.50; I haven't had time to look it over and see exactly what it does, but presumably this one should work for you.

I apologize in advance for any errors or omissions in all the instructions below.

# 1.45 (Greg Lowney)
# - added -x (for XML) option and handling of Custom Fields (formerly known as Extra Fields),
# see additional notes below.
# - add images in the order they were specified unless -s (for Sort) is specified.
# (sorting alphabettically used to be automatic, always.)
# - album created by "-c newalbum" is now subfolder of "-a parentalbum" (else of the root).
# - added helper functions SmartJoin, CloseSentence.
# - factored usage/syntax display into Help() subroutine.

# Notes on -x (XML) option
# The -x command-line option tells the script to treat each file names on the command line
# as an XML file listing files to be added.
#
# It does not matter what the XML root and record tags are called; we treat all child records
# of the root as describing images to be uploaded. (We should improve that.)
#
# All values under the image record are considered "facts" and will be added as Custom Field
# values for that image in the gallery.
# The script does not care whatindividual facts (tags) are provided for each image,
# except that it does provide special handling for a few pre-defined facts:
# 1) We combine Notes, Notes1, and Notes2 into Notes.
# 2) If Caption is not specified, we try Combined_Caption, otherwise we create a
# caption by putting together Title, Description, and Filename fields.
#
# IMPORTANT NOTE: In the end all facts will be ignored unless you're adding the images to
# albums that have corresponding Custom Fields. (Gallery Remote Protocol does not allow us to
# add new Custom Fields to albums, so you have to do that through the Gallery UI.)
#
# The format of the file can look like this:
#
# <XML_ROOT>
# <XML_RECORD>
# <Roll>greg's digital 2005\2005_06_19 (Fremont Festival)</Roll>
# <Shot>30</Shot>
# <Filename>2004-10-05_16.02.13_IMGP0563.JPG</Filename>
# <Date>10/5/2004</Date>
# <Subjects>Jane Doe; John Doe</Subjects>
# <Scene>Fremont Festival 2005</Scene>
# <Title>Mark gets a cleaver through his head.</Title>
# <Description>Thanks to The Spoon Man for cutlery.</Description>
# <Rating>3</Rating>
# </XML_RECORD>
# </XML_ROOT>
#

Installing required Perl modules

Using the -x (XML) option requires the the XML::Twig module be installed in your Perl installation. You can downlist this from CPAN, but I realize most people aren't familiar with how to do that. (I don't know if any CSV parsing modules are installed by default, either.) If you run the script with -x and get an error saying that Twig isn’t installed, you can probably install it using the following steps:

To install the XML::Twig Perl module using ActiveState Perl under Windows:

  1. Start a command prompt by choosing Run from the Start menu, entering "cmd" (without the quotes), then pressing the ENTER key
  2. Type "ppm3" (without the quotes) to start the Perl Programmer's Package Manager, and it will start prompting you with the string "ppm>"
  3. Type "Install XML::Twig" (without the quotes) and press ENTER
  4. CD to the location where your copy of Perl is installed (and I’m afraid you’re on your own for that part)
  5. Type "q" (without the quotes) and press ENTER to exit Perl Programmer's Package Manager

To install the XML::Twig Perl module using ActiveState Perl under Linux:

  1. At a shell prompt, type "perl -MCPAN -e 'install XML::Twig'" (without the double-quotes) and press ENTER.

Installing and Using the Excel Macros

If you want to turn your Excel spreadsheet or CSV file into XML to be used with the -x option, I have an Excel macro that will do it, and recent versions of Microsoft Excel might have the capability built-in.

WriteDatabaseSelectionAsGenericXML.txt contains a number of Excel macros. To install it, follow these steps:

  1. Start Notepad and open WriteDatabaseSelectionAsGenericXML.txt
  2. Choose Select All from the Edit menu
  3. Choose Copy from the Edit menu
  4. Close Notepad
  5. Start or switch to Excel
  6. Choose Macro, Macros… from the Tools menu, which will open Microsoft Visual Basic
  7. Type “WriteDatabaseSelectionAsGenericXML

[/]

[/]