I have very little Perl experience.
I need to read a binary image in and pass it to the Image::ExifTool module.
Here is my code:
use Image::ExifTool;
my $exifTool = new Image::ExifTool;
open(IMAGE, $file) || die "Can't Open $file\n";
binmode(IMAGE);
my ($buf, $data, $n);
while (($n = read FILE, $data, 4) != 0) {
$buf .= $data;
}
#'.=' is concat
print $file .= " test";
$infob = $exifTool->ImageInfo(\$buf);
foreach ( keys %$infob ) {
print "$_ => $$infob{$_}\n";
}
close(IMAGE);
As far as I can tell, my above code reads in the reference file and appends at the byte level the binary data to $buf.
As per the ExifTool documentation, you can pass an in memory reference to a file as a scalar var to the ImageInfo method — this is done above.
When executed, the Image::ExifTool module spits out the following:
Error => Unknown file type
1 Answer