ExifTool Forum

ExifTool => Developers => Topic started by: Curtis on December 26, 2015, 09:35:15 PM

Title: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 26, 2015, 09:35:15 PM
By giving just a set of tag values ( 'on the command line') I would like to get from exiftool XML output (using the -X command).  With the -o command I can do this to create an XMP file (and other formats) but this only gives me the XMP tags, not the others.

I create the XMP file like this: (of course I don't get the IDF0 values)
-q
-q
-sep
<!>
-E
-o
D:\Test Files\Test.XMP
-IFD0:ImageDescription=The New Description!!!!
-IFD0:Make=Canon
-IFD0:Model=Canon PowerShot S100
-IFD0:Software=aaaaaaaaaaaaaaaaaaaaaaaaaaa
-XMP-dc:Description=The New Description!!!!
-XMP-plus:CopyrightOwner=[{CopyrightOwnerID=CO ID Line 1,CopyrightOwnerName=CO Name Line 1},{CopyrightOwnerID=CO ID Line 2},{CopyrightOwnerName=CO Name Line 3},{CopyrightOwnerID=CO ID Line 4},{CopyrightOwnerName=CO Name Line 5}]
-execute


Ideally I would like to just be able to use an XML file name extension, but exiftool does not support that.

So I tried:
-q
-q
-sep
<!>
-E
-IFD0:ImageDescription=The New Description!!!!
-IFD0:Make=Canon
-IFD0:Model=Canon PowerShot S100
-IFD0:Software=aaaaaaaaaaaaaaaaaaaaaaaaaaa
-XMP-dc:Description=The New Description!!!!
-XMP-plus:CopyrightOwner=[{CopyrightOwnerID=CO ID Line 1,CopyrightOwnerName=CO Name Line 1},{CopyrightOwnerID=CO ID Line 2},{CopyrightOwnerName=CO Name Line 3},{CopyrightOwnerID=CO ID Line 4},{CopyrightOwnerName=CO Name Line 5}]
-IPTC:Keywords=aaaa<!>bbbb<!>c<!>ddddddddddddddddddddd<!>wwwww<!>zzzzzzzzzzzzzzzzzzzzzzzzz
-struct
-X
-t
-l
-execute


....thinking I have set the tag values I want, now with the -X command I was hoping exiftool would return the XML string like it does when I provide a file to get the tag values from, but it returns nothing and there is no error message either.

Is there a way with exiftool to get XML output with just providing tag values 'on the command line' either as a string (-X) or written to a file (-o with XML file extension) or some other way?

Thanks!
Curtis
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Hayo Baan on December 27, 2015, 03:13:33 AM
If I understand you right, you basically want exiftool just to generate the XML for the tags you gave it on the command line?

Currently exiftool does not support reading and writing at the same time, so that won't work in one phase. Instead of using exiftool have you looked at other ways of creating the xml? Or does it have to be exiftool?
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 27, 2015, 03:31:54 AM
Hi Hayo,

I use exiftool extensively in my program, so I don't want to re-invent the wheel to write tags out in the exact same format (XML) that exiftool already can do with the -X option.

What I'm trying to do is save a set of tag values as an XML file (versus XMP, MIE, etc.).  I don't need to read the tag values from a file as I already  have the tag values from either user input and/or from using exiftool to read them from a file. I just want to write a set of tag values out (or get a text string) in XML format.  Currently exiftool will do this using the -o command but only for XMP, ICC, MIE, VRD, DR4, EXIF, EXV formats.  I did find a workaround, but is a little of a kludge.  Since MIE is the only format that writes out all the tag Groups (I think it is the only one) I use the -o option and my tag values to create a temporary .MIE file and then I read it back in with exiftool using the -X option and save the resulting XML string to a file.  If works, but given how powerful exiftool is, I was thinking there may be a more direct way that does not involve writing to an intermediate temporary file.

Thanks for any advice!
Curtis
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Phil Harvey on December 27, 2015, 11:37:45 AM
Hi Curtis,

How about this?:

exiftool -IFD0:Make=Canon -o -.mie | exiftool -X -IFD0:Make -

Here I generate a MIE file and pipe it directly to exiftool to extract the tag in XML format.  Alternatively, EXV files also support all standard metadata types.

This avoids having to create a temporary file if you can pipe commands like this.

- Phil
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 27, 2015, 01:45:45 PM
Hi Phil,

Good idea but I'm running exiftool as a process from my program using -stayopen and stdin & stdout to communicate with the  exiftool process so not quite as straight forward (for me).

So I tried what you said in my program using MIE format, but got nothing back from  exiftool after feeding the MIE data back into  exiftool.  So I thought maybe it is an issue with me saving the MIE output as a string (vb.net) instead of a byte array, so before testing that theory I tired to do the same using XMP as a test, since it is a text format.  I tried this with the following commands, but got the same result in that after  all the XMP data input to exiftool  I expect to get some output from  exiftool via stdout, but I don't get anything from stdout. I assume I'm probably not sending the XMP (MIE or EXV in the future) data correctly to exiftool.  Any ideas?

Thanks!
Curtis

sent to exiftool via stdinp:
-q
-q
-sep
<!>
-E
-o
-.XMP
-XMP-iptcExt:DigitalSourceType=http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture
-XMP-iptcExt:Event=Ampthill v Bishop's Stortford
-XMP-aux:ApproximateFocusDistance=49.7
-XMP-aux:Firmware=1.1.4
-XMP-aux:FlashCompensation=0
-XMP-aux:ImageNumber=0
-XMP-aux:Lens=EF400mm f/2.8L IS USM
-XMP-aux:LensID=184
-XMP-aux:LensInfo=400 400 undef undef
-XMP-aux:SerialNumber=630500369
-XMP-dc:Format=image/jpeg
-XMP-photoshop:ColorMode=3
-XMP-photoshop:DateCreated=2015:05:02 14:27:29
-XMP-photoshop:ICCProfileName=sRGB IEC61966-2.1
-XMP-photoshop:LegacyIPTCDigest=DB12DE58A84B09DF4D1F48DB6C0DE4A9
-XMP-plus:CopyrightOwner=[{CopyrightOwnerID=CO ID Line 1,CopyrightOwnerName=CO Name Line 1},{CopyrightOwnerID=CO ID Line 2},{CopyrightOwnerName=CO Name Line 3},{CopyrightOwnerID=CO ID Line 4},{CopyrightOwnerName=CO Name Line 5}]
-execute
-execute
-q
-q
-XMP-iptcExt:DigitalSourceType
-XMP-iptcExt:Event
-XMP-aux:ApproximateFocusDistance
-XMP-aux:Firmware
-XMP-aux:FlashCompensation
-XMP-aux:ImageNumber
-XMP-aux:Lens
-XMP-aux:LensID
-XMP-aux:LensInfo
-XMP-aux:SerialNumber
-XMP-dc:Format
-XMP-photoshop:ColorMode
-XMP-photoshop:DateCreated
-XMP-photoshop:ICCProfileName
-XMP-photoshop:LegacyIPTCDigest
-XMP-plus:CopyrightOwnerID
-XMP-plus:CopyrightOwnerName
-struct
-X
-t
-l
-execute
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.02'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:Iptc4xmpExt='http://iptc.org/std/Iptc4xmpExt/2008-02-29/'>
  <Iptc4xmpExt:DigitalSourceType>http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture</Iptc4xmpExt:DigitalSourceType>
  <Iptc4xmpExt:Event>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>Ampthill v Bishop&#39;s Stortford</rdf:li>
   </rdf:Alt>
  </Iptc4xmpExt:Event>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:aux='http://ns.adobe.com/exif/1.0/aux/'>
  <aux:ApproximateFocusDistance>497/10</aux:ApproximateFocusDistance>
  <aux:Firmware>1.1.4</aux:Firmware>
  <aux:FlashCompensation>0/1</aux:FlashCompensation>
  <aux:ImageNumber>0</aux:ImageNumber>
  <aux:Lens>EF400mm f/2.8L IS USM</aux:Lens>
  <aux:LensID>184</aux:LensID>
  <aux:LensInfo>400/1 400/1 0/0 0/0</aux:LensInfo>
  <aux:SerialNumber>630500369</aux:SerialNumber>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:format>image/jpeg</dc:format>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
  <photoshop:DateCreated>2015-05-02T14:27:29</photoshop:DateCreated>
  <photoshop:ICCProfile>sRGB IEC61966-2.1</photoshop:ICCProfile>
  <photoshop:LegacyIPTCDigest>DB12DE58A84B09DF4D1F48DB6C0DE4A9</photoshop:LegacyIPTCDigest>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:plus='http://ns.useplus.org/ldf/xmp/1.0/'>
  <plus:CopyrightOwner>
   <rdf:Seq>
    <rdf:li rdf:parseType='Resource'>
     <plus:CopyrightOwnerID>CO ID Line 1</plus:CopyrightOwnerID>
     <plus:CopyrightOwnerName>CO Name Line 1</plus:CopyrightOwnerName>
    </rdf:li>
    <rdf:li rdf:parseType='Resource'>
     <plus:CopyrightOwnerID>CO ID Line 2</plus:CopyrightOwnerID>
    </rdf:li>
    <rdf:li rdf:parseType='Resource'>
     <plus:CopyrightOwnerName>CO Name Line 3</plus:CopyrightOwnerName>
    </rdf:li>
    <rdf:li rdf:parseType='Resource'>
     <plus:CopyrightOwnerID>CO ID Line 4</plus:CopyrightOwnerID>
    </rdf:li>
    <rdf:li rdf:parseType='Resource'>
     <plus:CopyrightOwnerName>CO Name Line 5</plus:CopyrightOwnerName>
    </rdf:li>
   </rdf:Seq>
  </plus:CopyrightOwner>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>
-execute



Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 27, 2015, 02:07:48 PM
As a little background about the purpose of what I'm trying to accomplish, it is to create tag 'templates' I can create from tag data I have (either from user input and/or reading from a file with meta data in it) that are human readable and editable files.

So I could just use the MIE or EXV formats to save my template files, but they are not human readable.  Since exiftool can output all tag data in a nice XML format I thought that would be the easiest format to use.

I open to other ideas on how to accomplish this.....   :D

Thanks!
Curtis
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Phil Harvey on December 28, 2015, 10:44:10 AM
Hi Curtis,

If you are using "-@ -" to input command-line arguments via stdin you can't also use stdin for the input file.  Stdin ("-") may only be used for on thing at a time.

- Phil
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 28, 2015, 01:10:26 PM
Yup, that makes sense.  I'll just use a temporary file as I have set up now, it works. 

Too bad -o doesn't work with XML, but I'd imagine there is not much call for this anyway.

Thanks again for all your help!
Curtis
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Phil Harvey on December 28, 2015, 02:33:37 PM
Hi Curtis,

There is probably call for it, but adding this to the -o option would mean official support for XML, which would disappoint many people when they realized that their specific flavour of XML is not compatible with ExifTool.  XML is a real can of worms because I have seen at least a dozen incompatible schemas out there for storing metadata in this format.   (Hence the reason why it isn't officially supported.)  The -X option uses RDF/XML syntax and ExifTool tag names, but other than XMP I haven't seen RDF/XML used very often.

- Phil
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 28, 2015, 03:17:38 PM
Yes, I can imagine it would be a can of worms. But it seems it would be reasonable to support the exact same format that you use for -X output,  could call it RDF/XML .
Maybe for rev 10.50  :)

Thanks
Curtis
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Phil Harvey on December 28, 2015, 03:28:45 PM
Hi Curtis,

Yes, it does seem reasonable, but it would be more work than it seems, and there are a few logistic problems I would have to solve first.  (Not the least of which is that I would need to devise a way to recognize this type of file when autodetecting the file format when reading.)

- Phil
Title: Re: How to get XML output similar to XMP with -o OR using -X?
Post by: Curtis on December 28, 2015, 03:54:33 PM
Yes sounds like there would be more challenges than it would be worth. Using a temp file is working well..... I'm very happy for  exiftools  current flexibility.
Thank you for a great  tool and always your quick responses !
Curtis