John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

I want to write a simple script to rename digital photo files. The counter on the camera sometimes gets reset (so all files are not unique anymore) and I'm combining pictures from several cameras. If I name all the files after the shooting time (in a suitable text representation), they will all sort together in chronological order, regardless of which camera they came from.

The file time is not useful because it sometimes gets lost, and editing the file (even turning it 90 degrees) "touches" it.

The time the picture was taken is recorded inside the JPEG file. All the cameras used by my family (and probably any modern camera) uses the EXIF records, which is embedded in the file. Tools like Thumbs Plus will show this information.

How can I read that info in Perl? Has anyone already come up with a EXIF record reader module, or does one of the graphics modules include this ability?

Thanks,
—John

Replies are listed 'Best First'.
Re: reading EXIF tags in JPEG files ?
by liz (Monsignor) on Aug 08, 2003 at 15:35 UTC
    Have you tried Image::Info ? I remember seeing a lot of extra information being returned for certain JPEG files...

    Liz

      Thanks for the reference. His notes indicate that the spec is now available, which is a big improvement from the last time I looked when the only thing available on the web was some weak reverse-engineering notes.
      FWIW, I downloaded Image::Info and it failed t\exif. Funny, since that's what I needed it for.
Re: reading EXIF tags in JPEG files ?
by mattriff (Chaplain) on Aug 08, 2003 at 15:35 UTC
Re: reading EXIF tags in JPEG files ?
by blue_cowdawg (Monsignor) on Aug 08, 2003 at 15:41 UTC

    Things to check out:

    I'm sure I missed a few.


    Peter @ Berghold . Net

    Sieze the cow! Bite the day!

    Test the code? We don't need to test no stinkin' code! All code posted here is as is where is unless otherwise stated.

    Brewer of Belgian style Ales

Re: reading EXIF tags in JPEG files ?
by monktim (Friar) on Aug 08, 2003 at 15:42 UTC
Re: reading EXIF tags in JPEG files ?
by RMGir (Prior) on Aug 08, 2003 at 15:40 UTC
    blue_cowdawg said it best: Deja Vu!.

    havoc asked a very similar question last week, and the posts in that thread might be helpful.
    --
    Mike

      Interesting that "EXIF" doesn't find anything on Super Search (only some false hits), not even this very thread (which doesn't worry me since it may not be indexed yet or something). But it led me to beleive that EXIF had never been uttered in the Monistary before now.
        Super Search does indeed pick up this thread as well as JPEG EXIF headers and Perl ... but not on the first page of results. If you click the "Next >" button one or two times, you will find them on the second or third page of results. Super search is set up to only search so much of the database at a time - it starts (unfortunately) at the beginning, and works it's way to the present. Now, if you had searched for titles that contain "EXIF", you will find this thread and the other on the first page of results.

        Just trying to keep the record straight ... ;)

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
        s/Super //; :)

        Plain un-super Search for EXIF worked fine.

        It's odd what gets picked up by Super Search, what gets found by Search, and when Google is the answer.
        --
        Mike