ExifTool Forum

ExifTool => Developers => Topic started by: Mac2 on November 21, 2021, 07:22:22 AM

Title: Question regarding the -JSON output and val/num
Post by: Mac2 on November 21, 2021, 07:22:22 AM
Depending on the tag and data type, ExifTool usually outputs (both for -X and -JSON) a val (formatted) and/or num value.
For some tags, however, I don't see any reason to output both, because val and num are identical. For example XMP::xmpMM::XMP:History or XMP::iptcExt:XMP:LocationShown. At least these are the two tags I've found so far.

Example:
    "XMP:LocationShown": {
      "desc": "Location Shown",
      "id": "LocationShown",
      "num": [
        {
          "City": "Frankfurt am Main",
          "CountryName": "Germany",
          "ProvinceState": "Hessen",
          "Sublocation": "Gutleutviertel"
        }
      ],
      "table": "XMP::iptcExt",
      "val": [
        {
          "City": "Frankfurt am Main",
          "CountryName": "Germany",
          "ProvinceState": "Hessen",
          "Sublocation": "Gutleutviertel"
        }
      ]
    },


Is there a reason for this or is this just a glitch?
I'm currently rewriting my ExifTool -> Database import routine and I wonder if I should import both data sets in such cases (because, one day, there may be different contents in val and num...).

Also: Different data type used for num for the same tag (in different groups):

    "EXIF:YCbCrSubSampling": {
      "desc": "Y Cb Cr Sub Sampling",
      "num": "2 2",
      "table": "Exif::Main",
      "val": "YCbCr4:2:0 (2 2)"
    },


but

    "XMP:YCbCrSubSampling": {
      "desc": "Y Cb Cr Sub Sampling",
      "num": [
        2,
        2
      ],
      "table": "XMP::tiff",
      "val": "YCbCr4:2:0 (2 2)"
    },


In the first case num contains a string with numbers separated by a blank, in the second case num is an array with two numbers.
Why are two different data types used, and when? I would like to unify the numeric representation in my database for these cases.
Title: Re: Question regarding the -JSON output and val/num
Post by: Phil Harvey on November 21, 2021, 08:15:39 AM
Right.  Structures weren't being tested to see if they were equal.  I'll fix this in the next version.

- Phil
Title: Re: Question regarding the -JSON output and val/num
Post by: Mac2 on November 21, 2021, 11:03:21 AM
Cool! Thanks  :)

And the string vs array difference?
Title: Re: Question regarding the -JSON output and val/num
Post by: Phil Harvey on November 21, 2021, 04:49:34 PM
Sorry, I didn't read that far.

That difference I can't fix.  All multi-valued integer EXIF tags are returned as a string of space-delimited numbers.  In XMP these are typically stored in some sort of list, but not always.  It would break things badly if I started returning multi-valued EXIF tags in list form.

- Phil
Title: Re: Question regarding the -JSON output and val/num
Post by: Mac2 on November 22, 2021, 06:39:27 AM
Thanks for explaining. I can live with that, I was just wondering.
I will unify this somehow when I import the data into the database.