Text::Query and Getopt::Long

Paul Archer gave an interesting talk that covered the modules Image::IPTCInfo, Getopt::Long, and Text::Query. He described these modules in the context of his program iptckeyword.

Apparently, there are (at least) two standards for addig metadata to images. The EXIF format is great for storing information about the event of taking a picture (time and date, etc.) but not really good at containing metadata about the subject. The IPTC format was created back in the '70s for keeping up with the information that the news services needed to keep with pictures (including subject, photographer, copyright, and keywords).

The iptckeyword program supports manipulating the keyword portion of the metadata stored with the images. The program also supports searching groups of images based on these keywords.

Paul showed how Getopt::Long was used to handle command line parameters to control the program. He also showed the use of Test::Query to allow the use of boolean expressions to search the keywords in the images. The Image::IPTCInfo module is used to actually manipulate the IPTC information in the images.

The example code will be added to the site in a few days.

As an added bonus, Paul talked about setting up a MythTV system and volunteered to answer questions on the subject, if you would like to set one up for yourself.


Here are the files from Paul's talk. I'm also including his description below.

A little background: IPTC is (among other things) a standard for embedding information into digital image files. Unlike EXIF, IPTC is primarily intended for user-supplied data. (EXIF is almost all camera/scanner generated data.)

One of the most useful parts of IPTC (for me, anyway) is the ability to give each file multiple keywords, and then be able to search by those keywords. That's what I wrote iptckeyword to do.

I despaired of writing a good (decent, or even usable) parser for searching, so I asked the Perl Beginner Mailing List, and Randal pointed me towards Text::Query::ParseAdvanced. It took a bit of fiddling to get working, but the code to utilize it is actually only a few lines long, and it does a great job. The only (minor) caveats are 1) you need to quote your search string so the shell sees it as a single argument, and 2) it produces two warnings about prototypes if you use the 'perl -w' construct on the shebang line.

Play with it a bit, and it'll be pretty obvious how it works. There are a couple of hints in the POD ('perldoc iptckeyword'), too.

Find a jpeg or two (say foo.jpg and bar.jpg).