Image::EXIF troubles

D

David Dyer-Bennet

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).
 
A

A. Sinan Unur

David Dyer-Bennet said:
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.
 
D

David Dyer-Bennet

A. Sinan Unur said:
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;
 
A

A. Sinan Unur

....

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__
 
M

Martin Herrmann

David Dyer-Bennet said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top