ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: Hayo Baan on July 20, 2014, 04:28:39 AM

Title: How to get all warning and error messages
Post by: Hayo Baan on July 20, 2014, 04:28:39 AM
Hi Phil, I'm looking for a way to retrieve ALL warnings and errors when using Image::ExifTool.

For instance, I have an image that contains two problems. When using exiftool -warning on the file, I get the following two warnings:
Warning                         : ICC_Profile pointer references previous ICC_Profile directory
Warning                         : Bad format (5836) for IFD0 entry 23


However when retrieving the warning in a script using $exiftool->GetValue("Warning"), I only get one of the two warnings (the first one).

Similarly, when writing to the file after changing some tags, I do not get the full list of errors and warnings. This is what exiftool on the command-line reports:
Warning: Duplicate ICC_Profile tag in IFD0
Error: [minor] ICC_Profile pointer references previous ICC_Profile directory
Error: Bad format (5836) for IFD0 entry 23


And this is what I get in the script:
Error:   [minor] ICC_Profile pointer references previous ICC_Profile directory
Warning: Duplicate ICC_Profile tag in IFD0


So, is there a way to get all warnings and errors when using the Image::ExifTool object?

Thanks,
Hayo
Title: Re: How to get all warning and error messages
Post by: Hayo Baan on July 20, 2014, 05:41:29 AM
Right,

With a little testing, I answered my own question already ;)

I can simply make use of $exiftool->GetInfo to retrieve all of them. To avoid confusion to others, perhaps you should make a note of this in the Image::ExifTool documentation. I (wrongly) interpreted the Warnings "tag" to be special in that only GetValue would retrieve it, but this turns out not to be the case. A simple note in the documentation could make this clearer:
QuoteNote: GetValue retrieves only one warning or error message. To retrieve them all, use GetInfo instead.

Cheers,
Hayo
Title: Re: How to get all warning and error messages
Post by: Phil Harvey on July 20, 2014, 09:27:24 AM
Hi Hayo,

Thanks for the suggestion.  I think the place to mention this is in the second paragraph describing the METHODS.  I will change it to this:

       None of these methods should ever die or issue warnings to STDERR if
       called with the proper arguments (with the exception of "SetNewValue"
       which may send an error message to STDERR, but only when called in
       scalar context).  Error and warning messages that occur during
       processing are stored in the values of the Error and Warning tags, and
       are accessible via the "GetValue" method to retrieve a single Error or
       Warning message, or "GetInfo" to retrieve any number of them.

Yes, these tags are handled just like any other tag.

- Phil
Title: Re: How to get all warning and error messages
Post by: Hayo Baan on July 20, 2014, 09:47:06 AM
Excellent!