MWG RegionInfo returned in JSON format is wrong...

Started by sebutzu, January 04, 2025, 06:44:34 PM

Previous topic - Next topic

sebutzu

When I get values in JSON for MWG RegionInfo I get all kinds of strange things:
"RegionList": [{
      "Area": {
        "H": "0.08813364058732986",
        "Unit": "normalized",
        "W": "0.05125432461500168",
        "X": 0.598075270652771,
        "Y": 0.3986175060272217
      },

or
"Area": {
        "H": "0.06826037168502808",
        "Unit": "normalized",
        "W": "0.04368511959910393",
        "X": 0.3118512034416199,
        "Y": "0.43706798553466797"
      },

For some reason, some of the values (not all, not the same always) come inside quotes, others not.
I would assume since the tags for X, Y, W, H are defined as real, I would always get them as numbers in JSON, not sometimes as numbers sometimes as strings.
It is quite impossible to work with this in an application, without having any type guarantees on what the JSON contains.
Is there something I can do? It would be nice if this things would behave in a predictable way, if I ever hope to parse this kind of JSON data in an application.
Thanks a lot for any help or suggestions.

StarGeek

#1
If exiftool thinks the value is a number, then it will be returned without quotes. Though I don't know why exiftool isn't doing so in this case.

You can add the -api StructFormat option with -api StructFormat=JSONQ which will force quotes around numbers.

Phil would have to comment further on this.

edit: One thing I should point out is that number of decimal places far exceeds what is needed. You would probably need an image millions (billions?) of pixels in size for the 15th decimal place to ever affect the region.

The old Google Picasa program would ignore any regions that had more than 9 decimal places. I currently use Photool's Imatch which reduces it to 6 decimal places, which would still be accurate on an image up to 500,000x500,000 pixels (half a pixel with each ±0.000001 change).
"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

I seem to recall that some JSON parsers had a limit on the number of significant digits in a floating point value, so more than this and it is passed as a string.

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