When using json and group options, dupe tags in array not extracted

Started by Archive, May 12, 2010, 08:54:36 AM

Previous topic - Next topic

Archive

[Originally posted by djeyewater on 2009-05-21 19:20:29-07]

Hi Phil,

I have a file with xmp as follows:

Code:
<dk:Websites>
    <rdf:Bag>
         <rdf:li rdf:parseType="Resource">
             <dk:WebsiteName>Flickr</dk:WebsiteName>
             <dk:ImageURL>http://flickr.com/myphoto.jpg</dk:ImageURL>
         </rdf:li>
         <rdf:li rdf:parseType="Resource">
             <dk:WebsiteName>Red Bubble</dk:WebsiteName>
             <dk:ImageURL>http://redbubble.com/myphoto.jpg</dk:ImageURL>
         </rdf:li>
    </rdf:Bag>
</dk:Websites>

Using the -j and -g options when extracting, I just get the following as part of the XMP json object:

Code:
"WebsitesWebsiteName": "Flickr",
"WebsitesImageURL": "http://flickr.com/myphoto.jpg"
(Only the first item in the Websites array is extracted)

I would have expected something like:

Code:
"Websites: [
   {
      "WebsiteName": "Flickr",
      "ImageURL": "http://flickr.com/myphoto.jpg"
   },
   {
      "WebsiteName": "Red Bubble",
      "ImageURL": "http://redbubble.com/myphoto.jpg"
   }
]

I haven't tested with the IPTC4XMPExt LocationShown and LocationCreated properties, but I think I would get the same results as they have the same structure as my example.

Is there a way I can extract all the entries in the Websites array when using json output?

Thanks,

Dave

Archive

[Originally posted by exiftool on 2009-05-22 11:27:22-07]

Hi Dave,

Thanks for pointing this out.  ExifTool should be setting the List flag
for these tags.  I will fix this in the next release (7.77).  This change
only applies to unknown tags in structures within lists.  The LocationShown
and LocationCreated tags are extracted as Lists, but not as you expect:

Code:
 "LocationCreatedCity": [ "one", "two" ],
  "LocationCreatedCountryCode": [ 1, 2 ],

This will be the way that your tags are extracted in version 7.77.

I have it on my list to improve ExifTool's handling of XMP structures to
allow the original structure to be preserved, but currently they are flattened,
which may not be ideal for your situation.

- Phil

Archive

[Originally posted by exiftool on 2009-05-22 14:24:27-07]

I have run some tests and I take back what I said about changing
the behaviour for version 7.77.  There may be some complex
unknown structures which really shouldn't be treated like this.

I need to think more about how this should be done.

- Phil

Archive

[Originally posted by djeyewater on 2009-05-22 15:09:00-07]

Thanks

Dave

Archive

[Originally posted by exiftool on 2009-05-25 13:20:08-07]

Hi Dave,

I have prepared a
7.77
pre-release
which includes a new -struct option that affects the
formatting of the -json output:

Code:
> exiftool a.xmp -j -g -struct -xmp:all
[{
  "SourceFile": "a.xmp",
  "XMP": {
    "XMPToolkit": "Image::ExifTool 7.77",
    "Websites": [{
      "ImageURL": "http://flickr.com/myphoto.jpg",
      "WebsiteName": "Flickr"
    },{
      "ImageURL": "http://redbubble.com/myphoto.jpg",
      "WebsiteName": "Red Bubble"
    }]
  }
}]

Hopefully you are using the Perl version so you can try out this
pre-release.

Let me know what you think.

- Phil

Archive

[Originally posted by djeyewater on 2009-06-03 22:06:36-07]

Hi Phil

Sorry for delay in replying, only saw your post this evening. I've done some quick tests, and other than a slight problem writing, -struct seems great!

I took an image, and running exiftool -j -g -struct I got

Code:
"Websites": [{
      "WebsiteName": "Red Bubble"
    },{
      "ImageURL": "http://flickr.com/myImg",
      "WebsiteName": "Flickr"
    }]
which is correct

Then I did
Code:
-XMP-dk:WebsitesImageURL=oneURL -XMP-dk:WebsitesWebsiteName=oneName -XMP-dk:WebsitesImageURL=twoURL -XMP-dk:WebsitesWebsiteName=twoName
Ran exiftool -j -g -struct again, and got
Code:
"Websites": [{
      "ImageURL": "oneURL",
      "WebsiteName": "oneName"
    },{
      "ImageURL": "http://flickr.com/myImg",
      "WebsiteName": "twoName"
    },{
      "ImageURL": "twoURL"
    }]
which isn't what I was expecting

I also tested both the below, which worked correctly:

I tried an image with only entry in the dc:Subject tag array, with -struct the subject tag is extracted as an array "Subject": ["a keyword"] (what I would expect), without it is extracted as a string "Subject": "a keyword"

I tried extracting -LocationCreatedCity, with -struct I get nothing, and without -struct I get the tag as before, this seems a sensible way to do it to me.

Regards

Dave

Archive

[Originally posted by exiftool on 2009-06-03 23:21:09-07]

Hi Dave,

Yes, writing structured information is not currently supported,
and when structures are written as individual tags it is difficult
to get the structure that one wants. This has been on my to-do
list for some time, but at least now I am starting to take steps
toward properly handling structures.

I decided to return all arrays in brackets when -struct is used,
but historically exiftool has always returned a simple string
if there is only one element in the array.  I didn't change this.

- Phil

Archive

[Originally posted by djeyewater on 2009-06-04 08:27:00-07]

Hi Phil

Well, if writing structured information is not currently supported, exiftool does a good job of it anyway. When I have used exiftool to write properties stored in structs, such as the IPTCExt Location info, exiftool has always created the xmp structure correctly. The only time I have found a problem is with this unusual situation. This isn't actually an issue for me as I don't think I would have any images with that particular xmp structure (one property stored in first element of the array, and two properties stored in the second element of the array).

I'm glad you decided to return arrays in brackets with -struct, as with the current version if I expected something to be an array, I would need to check if it was a string first in case it was an array with only one item.

Regards

Dave