ImageInfo on a specific tag fails if one file doesn't have that tag

Started by bexelbie, December 04, 2017, 03:51:09 AM

Previous topic - Next topic

bexelbie

This is probably a "you shouldn't write perl code late at night" error, however I don't see it.

---
use Image::ExifTool qw(:Public);
my @ioTagList;

foreach my $f (@ARGV) {
  my $info = ImageInfo($f, \@ioTagList, {Unknown => 1});
  print "Found this: $f => $$info{Apple_0x0011}\n";
  }
---

When called with a single file, this works as expected.  When called on a group of files, it works as expected until one file doesn't have this TAG (Apple_0x0011).  After that no more data for this TAG is ever returned.

Am I supposed to reset the ImageInfo call somehow?

Thanks,

bex

Phil Harvey

This is because ioTagList is updated with the returned tags.  You must re-initialize this list with the tag you want to extract before each call to ImageInfo().

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).