Saturday, 29 December 2007

Photographic Metadata

When I first started with an SLR camera, some 13 years ago, all camera magazines had the same advice for beginners: to improve your pictures, write down all the settings you used, such as aperture or shutter speed, so that you can go back to this information once you have the prints and understand why they came out the way they did. As a result, a serious photographer would always have a small notebook with him to write all this down. It was quite a time consuming process but essential for who wanted to improve. In this age of digital photography, it would seem sensible for the camera to store this information with the picture so that you can retrieve it later. And indeed they do, in metadata called EXIF data that is embedded in the image file. Software like Photoshop is able to read EXIF data but it's a bit overkill to fire Photoshop just to look at this data. And it would also be nice to be able to write scripts based on it, such as a script that selects all pictures taken at a particular focal length.

Such a tool exists: it's called, quite simply, ExifTool. The tool is written in Perl so should work on any system that has Perl installed. There is a package for Mac OS-X that makes it really trivial to install. A proper install on Linux is slightly more convoluted so here's how to do it on Ubuntu:

  1. Download the latest version from the web site, in my case version 7.08;
  2. Extract the content of the file:
    $ tar -xzf ./Image-ExifTool-7.08.tar.gz
    
  3. Install the Perl libraries so that they can be used by other Perl scripts:
    $ cd ./Image-ExifTool-7.08
    $ perl Makefile.PL
    $ make
    $ make test
    $ sudo make install
    
  4. Install the main script:
    $ sudo cp exiftool /usr/local/bin
    

Alternatively, you can use ExifTool directly from the directory where you extracted it if you just want to try it out. Using ExifTool in the command line is very easy, just call:

$ exiftool myfile.jpg

And it will output all the metadata tags it knows about. There are a number of options available, in particular, you can select what tags you want to see. It's all very well explained in the man page. And if you run exiftool without arguments, it will actually display said man page. So what sort of fun stuff can we do now? Here is an example that selects all the files with a .JPG extension in the current directory and below that are photographs taken with a focal length of 105mm:

$ for f in `find . -name "*.JPG"`; do
> if [ -n "`exiftool -FocalLength $f | grep '105.0mm'`" ]; then
> echo $f
> fi
> done

Note that ExifTool formats its output such that it prints out the name of the tag followed by a colon and the value. If you want to strip that name and only keep the value, you can do something like this:

$ exiftool -FocalLength myfile.jpg | sed 's/^[^:]*: //'

An interesting application, if you have a GPS receiver is to combine the GPS trace log with the EXIF time information to geo-tag your photographs. There are a number of links on the ExifTool web site that point to such utilities. Once geo-tagged, online photo sites like flickr will use this information to position the pictures on a map. Or more simply, to come back to what I was talking about at the beginning of this article, you could compare basic shot settings between pictures to understand why one is better than another.

Note that there are other tools than ExifTool to do this, some of them offer a graphic front-end that may be easier to use for those who are not comfortable with the command line, but ExifTool is by far the most complete and powerful. Just google for exif reader if you want to find other options.

Friday, 21 December 2007

Zend Framework on XAMPP

I am currently experimenting with the Zend Framework, using XAMPP on a Windows laptop and following Rob Allen's excellent tutorial. With a default installation of XAMPP, you get a nasty Error 500 whenever you test your system. This is because XAMPP doesn't enable the Apache mod_rewrite extension by default. So here's how to do it. Find the Apache configuration file, called httpd.conf, which on my install is in C:\xampp\apache\conf and uncomment the following line:

LoadModule rewrite_module modules/mod_rewrite.so

Restart XAMPP and it should all work.

Saturday, 15 December 2007

Road Rage

Why is it that being at the wheel of a car transforms most reasonable people in arrogant aggressive maniacs? I was just walking down the road when I saw this guy change lane, cutting off the driver behind in the process. Of course, the guy behind sounded his horn briefly to tell him he wasn't too happy about that manoeuvre. And what did the guy in front do as a result? Show him the finger. Well done for being an arse!