News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Hierarchical keyword read as array losing ordering

Started by Joanna Carter, July 07, 2021, 06:01:12 AM

Previous topic - Next topic

Joanna Carter

Hi folks

Here's a tricky one

I'm using -xmp-lr:hierarchicalsubject to retrieve hierarchical keywords from a file.

This works fine from the macOS Terminal, giving me


Anemonefish|Australian|Amphiprion rubrocinctus


as a single string value but, when I call it from a process in my app, I get an array returned in the JSON dictionary decoded from the data


(lldb) po jsonDict
▿ 2 elements
  ▿ 0 : 2 elements
    - key : "SourceFile"
    - value : /Users/joannacarter/Desktop/Anemonefish, Australian_IMG_1299.jpg
  ▿ 1 : 2 elements
    - key : "HierarchicalSubject"
    ▿ value : 3 elements
      - 0 : Amphiprion rubrocinctus
      - 1 : Anemonefish
      - 2 : Australian

With the words in the wrong order.

Is this possibly a problem with ExifTool or should I be looking to how the data is read?

Although the data reads into an UTF8 string as


"[{\n  \"SourceFile\": \"/Users/joannacarter/Desktop/Anemonefish, Australian_IMG_1299.jpg\",\n  \"HierarchicalSubject\": [\"Amphiprion rubrocinctus\",\"Anemonefish\",\"Australian\"]\n}]\n"

Phil Harvey

Hi Joanna,

I don't think this is an ExifTool question.  ExifTool will not split HierarchicalSubject on the "|" character.

You need to look at how your app is processing the ExifTool output.

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

Joanna Carter

Hi Phil

I was afraid of that. As far as I can tell, it's buried deep in the bowels of the Apple process mechanism  >:(

Joanna Carter

After all that, it turned out to be a very badly mal-formed hierarchicalsubject tag

Normal service has now been resumed  :)