ExifTool > The Image::ExifTool API

exif E8800 <> riff E8800


Alan Clifford:
As I'm stuck in South Africa for 3 weeks under lockdown, I thought I start processing some old photos.
I have a problem.  I hope the problem is me being an idiot!  On a macbook.

exiftool  test_2408.* -model -G -s
======== test_2408.nef
[EXIF]          Model                           : E8800
======== test_2408.wav
[RIFF]          Model                           : E8800
    2 image files read

My script recognizes the model from the .wav file but won't use it.  I am baffled.

Here is a snippet of my processing. I put angled brackets around $camera to see if there
was a space in there. And I've taken out a condition in the print of $prepend and it throws
error for the .wav file.

The script:

sub get_camera {
# returns camera prefix or unset
my $photo = shift ;
my ( $camera, $prepend ) ;
my $exifTool = new Image::ExifTool ;
$exifTool->Options(Duplicates => 0, IgnoreMinorErrors => 1);
my $info = $exifTool->ImageInfo($photo);

print STDERR "photo for exiftool is $photo\n" if $debugoption eq DEBUG ;

$camera = $exifTool->GetValue('Model', 'PrintConv');
if ($camera) {
  print STDERR "model:     <<$camera>>\n" if $quietoption ne QUIET ;
  # look for prefix in hash
  $prepend =  $camera_prepend{"$camera"} ;
#  print STDERR "prepend:   $prepend\n" if $prepend and $debugoption eq DEBUG ;
  print STDERR "prepend:   $prepend\n" if $debugoption eq DEBUG ;
else {
  print STDERR "model:     not available\n" if $quietoption ne QUIET ;
return $prepend ;  # could be undefined

This is what I get printed

photo for exiftool is ./test_2408.nef
model:     <<E8800>>
prepend:   e8800

photo for exiftool is ./test_2408.wav
model:     <<E8800>>
Use of uninitialized value $prepend in concatenation (.) or string
 at /Users/alan/photographs/scripts/temp_prepend_camera.pl line 311.

Phil Harvey:
Hi Alan,

I think the difference is that there is a null byte at the end of the camera model name in the RIFF metadata.  Try this:

--- Code: ---$camera = $exifTool->GetValue('Model', 'PrintConv');
$camera =~ s/\0.*//;
--- End code ---

- Phil

Alan Clifford:

--- Quote from: Phil Harvey on March 28, 2020, 09:36:53 PM ---

--- Code: ---$camera =~ s/\0.*//;
--- End code ---

--- End quote ---

Thanks Phil, that has fixed it.

I write so little Perl, I have difficulty even understanding my own stuff.

Does that mean substitute the null and everything after it with nothing?


Phil Harvey:


[0] Message Index

Go to full version