How access Group:Tag via Perl progamatically

Started by philW, July 16, 2023, 02:09:41 PM

Previous topic - Next topic

philW

Just a quick question after searching for hours.

How can I access the value of a specific tag in a specific group directly via Perl? And write to it, too?

my $exifTool = new Image::ExifTool;
my $info = $exifTool->ImageInfo( $img );

When fetching the value of $$info{'LensID'} I usually get the full lens specs, but depending on camera and lens also sometimes "Unknown (25521)", even though ID 25521 does exist in the ExifTool Minolta LensType hash. Obviously, the composite LensID tag gets queried via $$info{'LensID'}. However, there is also an XMP LensID tag with the real ID 25521 (from Adobe Photoshop, I assume).

Via console I can easily call exiftool -XMP-aux:LensID file. But how get and write via Perl?

Phil Harvey

There are two ways to get the tag with a specific group:

1. You can pass the tag key (the key in the $info hash) to GetGroup() to get the group for a tag. See here for the documentation.

or

2. You can pass a tag name with leading group to GetValue

And to you can specify a group in a similar manner when writing in the call to SetNewValue

- 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 ($).