IFD0 Tags from JSON to XMP

Started by notmetadataguru, August 07, 2020, 04:04:00 PM

Previous topic - Next topic

notmetadataguru

Hello,

I'm running into an issue where I have a set of IFD0 tags in a JSON file (exiftool JSON output) and I'm trying to convert it to XMP. The problem is that none of IFD0 tags are written to the XMP.

Here is the JSON (tags.json)
[
    {
        "sourceFile": "sidecar.xmp",
        "ifD0:Orientation": "Horizontal (normal)",
        "ifD0:XResolution": 240,
        "ifD0:YResolution": 240,
        "ifD0:ResolutionUnit": "inches",
        "ifD0:Make": "FUJIFILM",
        "ifD0:Model": "FinePix S5500"
    }
]


The command I'm running:
exiftool -@ exif2xmp.args -v3 -j=tags.json sidecar.xmp

exif2xmp.args is the standard args file that comes packaged with the tool

The output:
Reading JSON file tags.json
Imported entry for 'sidecar.xmp' (full path: '/mnt/c/dev-work/scratch/ifd0bug/sidecar.xmp')
======== sidecar.xmp
Setting new values from sidecar.xmp
Warning: Error opening file - sidecar.xmp
Setting new values from JSON database
Writing IFD0:Make
Writing IFD0:Make
Writing IFD0:Model
Writing IFD0:Model
Writing IFD0:Orientation
Writing IFD0:Orientation
Writing IFD0:ResolutionUnit
Writing IFD0:XResolution
Writing IFD0:YResolution
Creating XMP file...
  Error = Nothing to write
Error: Nothing to write - sidecar.xmp
    0 image files updated
    1 files weren't updated due to errors

StarGeek

If you run exiftool on the JSON file, you'll see this output
---- JSON ----
SourceFile                      : sidecar.xmp
IfD0Make                        : FUJIFILM
IfD0Model                       : FinePix S5500
IfD0Orientation                 : Horizontal (normal)
IfD0ResolutionUnit              : inches
IfD0XResolution                 : 240
IfD0YResolution                 : 240


As you can see, the tags are not EXIF tags, they're part of the JSON group.  So the exif2xmp.args file won't work.

Maybe Phil knows a good way to copy them.  All I can think of is to run exif2xmp.args when you first create the json, then follow the instructions in this post.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

This is tricky.  You either have to convert the tags to XMP before writing the JSON file as StarGeek suggests, or go through an EXIF-compatible file format afterwards, which could be done like this:

exiftool -j=tags.json -o -.exif | exiftool -tagsfromfile - -@ exif2xmp.args sidecar.xmp

But for this to work, the SourceFile in the JSON file would need to be "*".

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

notmetadataguru

Thank you for the quick response, your solution worked quite well!