How to get all warning and error messages

Started by Hayo Baan, July 20, 2014, 04:28:39 AM

Previous topic - Next topic

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

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
...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

Hayo Baan – Photography
Web: www.hayobaan.nl