ExifTool Forum

ExifTool => Developers => Topic started by: philW on July 16, 2023, 02:09:41 PM

Title: How access Group:Tag via Perl progamatically
Post by: philW on July 16, 2023, 02:09:41 PM
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?
Title: Re: How access Group:Tag via Perl progamatically
Post by: Phil Harvey on July 16, 2023, 09:28:09 PM
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 (https://exiftool.org/ExifTool.html#GetGroup) for the documentation.

or

2. You can pass a tag name with leading group to GetValue (https://exiftool.org/ExifTool.html#GetValue)

And to you can specify a group in a similar manner when writing in the call to SetNewValue (https://exiftool.org/ExifTool.html#SetNewValue)

- Phil
Title: Re: How access Group:Tag via Perl progamatically
Post by: philW on July 17, 2023, 03:38:08 AM
Thanks, Phil!