ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: StarGeek on June 11, 2023, 05:11:08 PM

Title: return a warning from a user defined tag
Post by: StarGeek on June 11, 2023, 05:11:08 PM
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")?
Title: Re: return a warning from a user defined tag
Post by: Phil Harvey on June 11, 2023, 09:35:04 PM
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
Title: Re: return a warning from a user defined tag
Post by: StarGeek on June 12, 2023, 10:54:00 AM
No worries then.