Image::EXIF troubles

Discussion in 'Perl Misc' started by David Dyer-Bennet, Nov 14, 2004.

  1. Anybody else using Image::EXIF to read exposure data and such out of
    image files from digital cameras? Or is there some other module that
    people like better for that?

    I find its error reporting confusing or unreliable or something. I've
    got a case where it doesn't read any data, but doesn't indicate
    $exif->error() either; but this is under mod_perl, and *doesn't*
    happen standalone, so it's probable running afoul of some restriction
    there (and I've asked on the mod_perl mailing list, no responses
    yet).
    --
    David Dyer-Bennet, <mailto:>, <http://www.dd-b.net/dd-b/>
    RKBA: <http://noguns-nomoney.com/> <http://www.dd-b.net/carry/>
    Pics: <http://dd-b.lighthunters.net/> <http://www.dd-b.net/dd-b/SnapshotAlbum/>
    Dragaera/Steven Brust: <http://dragaera.info/>
     
    David Dyer-Bennet, Nov 14, 2004
    #1
    1. Advertising

  2. David Dyer-Bennet <> wrote in news:-b.net:

    > Anybody else using Image::EXIF to read exposure data and such out of
    > image files from digital cameras? Or is there some other module that
    > people like better for that?
    >
    > I find its error reporting confusing or unreliable or something. I've
    > got a case where it doesn't read any data, but doesn't indicate
    > $exif->error() either; but this is under mod_perl, and *doesn't*
    > happen standalone, so it's probable running afoul of some restriction
    > there (and I've asked on the mod_perl mailing list, no responses
    > yet).


    Please post a short but complete script that exhibits the problem you are
    experiencing.

    Sinan.
     
    A. Sinan Unur, Nov 14, 2004
    #2
    1. Advertising

  3. "A. Sinan Unur" <> writes:

    > David Dyer-Bennet <> wrote in news:-b.net:
    >
    >> Anybody else using Image::EXIF to read exposure data and such out of
    >> image files from digital cameras? Or is there some other module that
    >> people like better for that?
    >>
    >> I find its error reporting confusing or unreliable or something. I've
    >> got a case where it doesn't read any data, but doesn't indicate
    >> $exif->error() either; but this is under mod_perl, and *doesn't*
    >> happen standalone, so it's probable running afoul of some restriction
    >> there (and I've asked on the mod_perl mailing list, no responses
    >> yet).

    >
    > Please post a short but complete script that exhibits the problem you are
    > experiencing.


    Here you go. Note that this runs under mod_perl; my current best info
    suggests that the module Image::EXIF isn't compatible with mod_perl --
    somewhere down in the underlying C utility code. I haven't chased it
    that deep.

    #! /usr/bin/perl

    # Testing Testing Testing

    use strict;
    use warnings;

    use Apache::Util;
    use Image::EXIF;
    use CGI;
    use Data::Dumper;

    use CGI::Carp 'fatalsToBrowser';
    $CGI::pOST_MAX = 5000;
    $CGI::DISABLE_UPLOADS = 1;
    my $q = new CGI;

    my $dir = "/web/dd-b/SnapshotAlbum/data/2004/09180-Birthday";

    my $fn = $dir . "/" . $q->param('fn');
    die "No such file as $fn" unless -r $fn;

    my @res = ();

    push @res, "File: ", $fn;

    my $exif = new Image::EXIF ();
    $exif->file_name($fn);
    push @res, $exif->error() ? $exif->errstr() : Dumper($exif->get_all_info);

    print $q->header,
    $q->start_html('test');
    print $q->pre(join ("\n", @res));
    print $q->end_html;

    $exif = undef;
    $q = undef;
    @res = undef;


    --
    David Dyer-Bennet, <mailto:>, <http://www.dd-b.net/dd-b/>
    RKBA: <http://noguns-nomoney.com/> <http://www.dd-b.net/carry/>
    Pics: <http://dd-b.lighthunters.net/> <http://www.dd-b.net/dd-b/SnapshotAlbum/>
    Dragaera/Steven Brust: <http://dragaera.info/>
     
    David Dyer-Bennet, Nov 14, 2004
    #3
  4. David Dyer-Bennet <> wrote in
    news:-b.net:

    > "A. Sinan Unur" <> writes:
    >
    >> David Dyer-Bennet <> wrote in
    >> news:-b.net:
    >>


    ....

    > Here you go. Note that this runs under mod_perl; my current best info
    > suggests that the module Image::EXIF isn't compatible with mod_perl --


    You might want to read

    http://perl.apache.org/docs/1.0/guide/porting.html#Exposing_Apache__Registr
    y_secrets (http://tinyurl.com/4f4a5)

    Also, running under mod_perl may mean different things depending on
    context. You should specify whether it is running as a so-called Registry
    script.

    > somewhere down in the underlying C utility code. I haven't chased it
    > that deep.


    I don't have time to either. I also don't have Image::EXIF on my system and
    don't have time to compile it. However, does the following code help?
    (untested).

    #! /usr/bin/perl

    # Untested

    use strict;
    use warnings;

    use Data::Dumper;
    use Image::EXIF;

    use CGI;
    $CGI::pOST_MAX = 5000;
    $CGI::DISABLE_UPLOADS = 1;

    use CGI::Carp 'fatalsToBrowser';
    use File::Spec 'catfile';

    use constant IMAGE_DIR =>
    '/web/dd-b/SnapshotAlbum/data/2004/09180-Birthday';

    run();

    sub run {
    my $q = new CGI;

    my $fn = CGI->param('fn');
    $fn = '' unless defined $fn;

    # Always untaint variables ... see perldoc perlsec
    if($fn =~ /^(\w+\.jpg)$/i) {
    $fn = $1;
    } else {
    $fn = '';
    }

    $fn = catfile IMAGE_DIR, $fn;

    die "Cannot read $fn: $!" unless -r $fn;

    my @res;
    push @res, "File: ", $fn;

    my $exif = Image::EXIF->new;
    $exif->file_name($fn);
    push @res, $exif->error ? $exif->errstr : Dumper($exif->get_all_info);

    print $q->header,
    $q->start_html('test'),
    $q->pre(join ("\n", @res)),
    $q->end_html;
    }
    }
    __END__
     
    A. Sinan Unur, Nov 14, 2004
    #4
  5. David Dyer-Bennet <> wrote in message news:<-b.net>...
    > Anybody else using Image::EXIF to read exposure data and such out of
    > image files from digital cameras? Or is there some other module that
    > people like better for that?


    Maybe you should try Image::MetaData::JPEG instead of Image::EXIF.
    It's written in pure perl and works quite good in my Perl/Tk picture
    viewer and organizer Mapivi (http://mapivi.de.vu).

    Regards
    Martin
     
    Martin Herrmann, Nov 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joaquin Corchero

    Writing EXIF file properties

    Joaquin Corchero, Dec 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    771
    Joaquin Corchero
    Dec 15, 2004
  2. Paul Archer
    Replies:
    2
    Views:
    410
    Paul Archer
    Apr 17, 2009
  3. David Dyer-Bennet
    Replies:
    1
    Views:
    161
    Martin Herrmann
    Nov 15, 2004
  4. Marcin Owsiany

    Proposal: Image::EXIF::DateTime::Parser

    Marcin Owsiany, May 8, 2009, in forum: Perl Misc
    Replies:
    2
    Views:
    149
    Marcin Owsiany
    May 11, 2009
  5. Replies:
    2
    Views:
    216
Loading...

Share This Page