return a warning from a user defined tag

Started by StarGeek, June 11, 2023, 05:11:08 PM

Previous topic - Next topic

StarGeek

The Guano tag got me thinking about how to check the version of exiftool in a user defined tag and if it was possible to add a warning if the version wasn't high enough.

It would be easy enough to add a check against ExifToolVersion to see if the version was 12.63 or greater for the Guano user defined tags and return undef if not.  Or maybe a response of "requires version 12.63" as the value of the tag.  But would it be possible to add a regular warning to the Warning tag?  And would it be possible to differentiate between minor and Minor (capital M "indicate that the processing is affected by ignoring the warning")?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

You could do this at the top of your the config file:

warn "Guano tags require ExifTool 12.63 or later\n" if $Image::ExifTool::VERSION < 12.63;
or this for each tag

        GuanoVersion => {
            Require => 'Guano',
            ValueConv => q{
                return 'Requires ExifTool 12.63 or later' if $Image::ExifTool::Version < 12.63;
                return (($val[0]=~m/GUANO\|Version:\s+(.*)/m)) ? $1 : undef;
            },
        },

But I'm not really happy with either solution.  I think it best to just leave it as a comment in the header.

You can't really generate a proper warning from a ValueConv because this code is called after the return tag list is generated.

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

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).