Get all validation warnings in json?

Started by jrochkind, September 12, 2023, 03:22:34 PM

Previous topic - Next topic

jrochkind

exiftool 12.60.

I have a particular corrupt/bad TIFF file.

If I run:

    exiftool -all:all -validate my_bad.tiff

It includes this output at the end:

    Warning                         : Missing required TIFF IFD0 tag 0x0100 ImageWidth
    Warning                         : Missing required TIFF IFD0 tag 0x0101 ImageHeight
    Warning                         : Missing required TIFF IFD0 tag 0x0106 PhotometricInterpretation
    Warning                         : Missing required TIFF IFD0 tag 0x0111 StripOffsets
    Warning                         : Missing required TIFF IFD0 tag 0x0116 RowsPerStrip
    Warning                         : Missing required TIFF IFD0 tag 0x0117 StripByteCounts
    Warning                         : Missing required TIFF IFD0 tag 0x011a XResolution
    Warning                         : Missing required TIFF IFD0 tag 0x011b YResolution
    Validate                        : 8 Warnings
    Validate                        : 8 Warnings

However, if I ask for `-json` output, it only includes the FIRST warning. It ignores the others. The `-a` or `-duplicates` flag doesn't seem to make a difference

    exiftool -a -all:all -validate -json my_bad.tiff

    ...
      "Warning": "Missing required TIFF IFD0 tag 0x0100 ImageWidth",
      "Validate": "8 Warnings"
    }]

Is there anything I can do to get the complete list of 8 Warnings in json output?

Is this a bug/missing feature?

StarGeek

From the docs on the -j (-json) option
QuoteThe -a option is implied when -json is used, but entries with identical JSON names are suppressed in the output. (-G4 may be used to ensure that all tags have unique JSON names.)
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

jrochkind

Quote from: StarGeek on September 13, 2023, 10:46:23 AMFrom the docs on the -j (-json) option
QuoteThe -a option is implied when -json is used, but entries with identical JSON names are suppressed in the output. (-G4 may be used to ensure that all tags have unique JSON names.)

Hey thanks!  -G4 alone doesn't do what I want, as I also wanted -G group prefixes, which I guess is an implied -G0.

After spending more time with the docs to try to figure these options out, `-G0:4` gets close.

Now for my warnings, I get, eg:

  "ExifTool:Warning": "Bad IFD0 directory",
  "ExifTool:Copy1:Warning": "Missing required TIFF IFD0 tag 0x0100 ImageWidth",
  "ExifTool:Copy2:Warning": "Missing required TIFF IFD0 tag 0x0101 ImageHeight",
  "ExifTool:Copy3:Warning": "Missing required TIFF IFD0 tag 0x0106 PhotometricInterpretation",

So I *am* getting them all... although this is not a very convenient way to get them in JSON for machine-readability, my software needs to look for keys with a certain pattern involving :CopyN to extract all warnings, instead of just looking up a known key like ExifTool:Warning1.

Meanwhile, while most of my other tags remain the same (eg say EXIF:ImageWidth), *some* of them get a Copy1 added for no apparent reason. For instance, XMP:Copy1:Make, even though there is no base XMP:Make tag, or other XMP:CopyN:Make.

Why for some tags does it insert `Copy1` but for others it does not?

If the goal of JSON output is machine processing, this is all actually pretty inconvenient for such processing, I need a lot of unexpected logic to find the values instead of just a simple key lookup.

I kind of wish there was a way to get multiple values with the same tag name as just a JSON *array*.

I wonder if this feature request has been made before, or if it is feasible and there might be other interest? Is there a good place to make this feature request?  [/code]

StarGeek

Anything else will have to wait until Phil gets back from vacation, which may be this week or next week.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Quote from: jrochkind on September 13, 2023, 03:15:35 PM*some* of them get a Copy1 added for no apparent reason. For instance, XMP:Copy1:Make, even though there is no base XMP:Make tag, or other XMP:CopyN:Make.

There must be some other Make tag.  (It doesn't have to be just XMP for it to be a copy.)

QuoteIf the goal of JSON output is machine processing, this is all actually pretty inconvenient for such processing, I need a lot of unexpected logic to find the values instead of just a simple key lookup.

This doesn't seem difficult to me.  Just s/:Copy\d+$// to remove the copy number before you do the lookup.

QuoteI kind of wish there was a way to get multiple values with the same tag name as just a JSON *array*.

How would you distinguish between this case and a single tag with multiple values (ie. a list of keywords)?  There is a difference.

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