Subject: | Second object creation for same filename fails |
If two requests are made to read the same Jpeg file, the second
request fails (silently).
This seems to be because when the (perl) object is destroyed, the
(static) C module (EXIF.xs) throws away the data, but doesn't clear
out the filename. A subequent object creation using the same filename
then fails because read_data finds a filename match, and thinks it
doesn't have to re-read the data.
I think this is can be fixed by moving _file_name so that it is
visible outside function read_data(), and then setting it to blank
from within close_application(), ie:
<<CODE FRAGMENT : EXIF.xs>>
static char _file_name[1024] = ""; // copied from below...
static int
read_data(char *fname)
{
// static char _file_name[1024] = ""; // moved above to widen scope
int mark, first = 0;
unsigned int len, rlen;
unsigned char *exifbuf = NULL;
FILE *fpn;
<.....>
static int
close_application()
{
if (et)
{
exiffree(et);
et = NULL;
strcpy(_file_name, ""); // clear out filename
}
}
<END CODE FRAGMENT>
Experienced on:
Distribution: libimage-exif-perl (1.00.3-2)
Perl version: 5.8.7
Operating system: Linux sarge 2.6.5-1-686 #5
Subject: | broken.pl |
#!/usr/bin/perl
use strict;
use Image::EXIF;
my $file1 = "DSCF0015.JPG";
my $file2 = "DSCN0001.JPG";
for my $file ($file1, $file1, $file2)
{
my $exif = new Image::EXIF($file)->get_all_info;
print "$file : " . ((defined $exif) ? "OK" : "Failed") . "\n";
}