Write Info of XML into JPG file

Started by TomWal, April 29, 2024, 02:57:53 PM

Previous topic - Next topic

TomWal

Hi, I'm new in this forum.
My question is: can I write XML information to a JPG file using exiftool?

My approach:
- I create a JPG file using Adobe Firefly

- write the XML information to an external XML file with the following command:
exiftool -X -G1:4 -e -struct -n -charset filename=utf8 myFile.jpg > myFile.xml

- the original file loses the XML information because another processing of the JPG file is carried out.

Is there an exiftool command that puts the complete XML information from the "myFile.xml" file back into the edited JPG file?

I look forward to a solution

Tom

Phil Harvey

Hi Tom,

Sure you can copy any information you want from the XML file to another file. To copy everything, you can do this:

exiftool -tagsfromfile %d%f.xml -all:all FILE

But if you extract with the -n option you'll have to use this when copying too.

And the -G1:4 has no effect on the -X output of your original command.

Also, you may want to add -b to your original command to copy binary-data values.

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

TomWal

#2
Thanks Phil, but it doesn't work correctly yet.

I created the following XML file:
--------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about='/Users/d311610/Desktop/Meta-Eintrag/Roh/Firefly_2_lustiges_Tierbild_006.jpg'
  xmlns:et='http://ns.exiftool.org/1.0/' et:toolkit='Image::ExifTool 12.74'
  xmlns:CBOR='http://ns.exiftool.org/JUMBF/CBOR/1.0/'>
<CBOR:Actions rdf:parseType='Resource'>
  <CBOR:action>c2pa.created</CBOR:action>
  <CBOR:softwareAgent>Adobe Firefly</CBOR:softwareAgent>
  <CBOR:digitalSourceType>https://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia</CBOR:digitalSourceType>
</CBOR:Actions>
</rdf:Description>
</rdf:RDF>
--------------------------------
I wrote it in the other file
exiftool -tagsfromfile myXML.xml -all:all myFile.jpg

then I get the following XML back from the JPG file:
--------------------------------
...
<File:Comment>&lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39;?&gt;
&lt;rdf:RDF xmlns:rdf=&#39;http://www.w3.org/1999/02/22-rdf-syntax-ns#&#39;&gt;

&lt;rdf:Description rdf:about=&#39;/Users/d311610/Desktop/Meta-Eintrag/Roh/Firefly_2_lustiges_Tierbild_006.jpg&#39;
  xmlns:et=&#39;http://ns.exiftool.org/1.0/&#39; et:toolkit=&#39;Image::ExifTool 12.74&#39;
  xmlns:CBOR=&#39;http://ns.exiftool.org/JUMBF/CBOR/1.0/&#39;&gt;
&lt;CBOR:Actions rdf:parseType=&#39;Resource&#39;&gt;
  &lt;CBOR:action&gt;c2pa.created&lt;/CBOR:action&gt;
  &lt;CBOR:softwareAgent&gt;Adobe Firefly&lt;/CBOR:softwareAgent&gt;
  &lt;CBOR:digitalSourceType&gt;https://cv.iptc.org/newscodes/digitalsourcetype/trainedAlgorithmicMedia&lt;/CBOR:digitalSourceType&gt;
&lt;/CBOR:Actions&gt;
...
--------------------------------
The old tags are correct. The new tags are not correctly.

Where is my mistake?
(For your information: I work on a Mac)
- Tom

Phil Harvey

Hi Tom,

My command only works for XML produced by the ExifTool -X output.  It must use the ExifTool namespaces to be able to import it with -all:all.

I don't know what you are trying to do with the CBOR namespace.  Perhaps you want to write this to XMP?  I think you have to step back and figure out exactly what you want to write and where.

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