Adding warnings from within a custom tag

Started by Hayo Baan, April 13, 2019, 07:29:33 AM

Previous topic - Next topic

Hayo Baan

Hi Phil,

I'd like to be able to add warnings when inside a custom tag (e.g. in the printconv or valueconv code) . Is this possible and if possible, how do I do so in the most elegant way?

Thanks,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Hayo,

This is a bit tricky.  In general, warnings should be generated before the ValueConv because by this time the calling program already has a list of tags that have been extracted.  So even though you generate a new warning tag, it may not be noticed.  It will work from a RawConv, but at that point  you only have access to the raw values of the other tags via @raw.  To generate a warning, do this:

$self->Warn("some warning");

Only in the case when no tags were extracted does the exiftool application go back to check the warnings for a second time.  So in this case a warning in the ValueConv would be shown.

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

Hayo Baan

Hmm, it's a pity I can really only add warnings in rawconv. For this particular instance it does not matter; I want to provide a tag that always returns the three letter ISO country code even if the two letter country code was used (in this case I want the warning to be shown). This I can do in rawconv too, but in other cases it would be nice to be able to add warnings in e.g. valueconv.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

BTW, the complete documentation for stuff like this is here, which says this in the RawConv description:

                  RawConv may generate Warning or Error tags, while
                  ValueConv and PrintConv should not (see ValueConv note below).


with this note in the ValueConv documentation:

                  Note:  Warnings issued by these conversions are intercepted by
                  ExifTool and saved as Warning tags, but since ValueConv and
                  PrintConv conversions are done on demand, the warnings may be
                  generated after the list of extracted tags is returned, so may
                  easily be missed.


I have thought about this a bit more, but I can't see an easy way around this.

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

Hayo Baan

OK, I can live with not having this ;D

Thanks for the link with the full info. It's so easy to overlook the part where things are documented...
Hayo Baan – Photography
Web: www.hayobaan.nl