Author Topic: adding xmp data  (Read 3548 times)

themanwho

  • Newbie
  • *
  • Posts: 4
adding xmp data
« on: November 08, 2010, 04:44:21 PM »
Forgive me for being new and asking what may be a far-too-simple question, but the answer is not jumping out at me...

I would like to add xmp data to a tif file where the input is an existing xmp.xml file on disk.  I see how to do this element by element, but am I able to attach an entire xml file?  I have tried

exiftool -XMP=<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> etc etc

but it returns the error:

Invalid XMP data for XMP:XMP

I am assuming the xml is valid, because I am trying to input the xmp that I have just extracted using exiftool -b -XMP

Any help for a total newbie?

TIA...


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14759
    • ExifTool Home Page
Re: adding xmp data
« Reply #1 on: November 08, 2010, 06:08:22 PM »
There are a number of ways to do what you want.

First, valid XML is not necessarily valid XMP, so we must be careful here.

If it is valid XMP, then you can do this:

exiftool "-xmp<=xmp.xml" FILE

to insert the XMP as a block in a file.

Typing the XMP in as you did would also work, but you would need to put quotes around it because it contains special characters.  However, this would be tedious.

Finally, the method I would suggest is to let ExifTool create the XMP block and copy all readable tags from your file.  Then you are sure the XMP you write is properly formatted:

exiftool -tagsfromfile xmp.xml "-all>xmp:all" FILE

With this command, the source file (xmp.xml in the command above) could be any format... XML, TIFF, JPEG, whatever, and ExifTool will take all of the available information and copy it to same-named XMP tags if they exist, then insert these into the output FILE.

I hope this makes a bit of sense.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

themanwho

  • Newbie
  • *
  • Posts: 4
Re: adding xmp data
« Reply #2 on: November 09, 2010, 08:49:50 AM »
Phil,
Thanks a million -- methods 1 and 3 work perfectly.  I will go with your recommendation: #3 even though I seemingly have valid xmp (since #1 works).  All this is to turn something around rather quickly, so long term I expect to use the perl module, which will no doubt prompt more questions.

Again, thanks!
Bill

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14759
    • ExifTool Home Page
Re: adding xmp data
« Reply #3 on: November 09, 2010, 09:00:56 AM »
Hi Bill,

Great, glad this helped.

One thing I should mention is that method number 3 has the limitation that only writable XMP tags will get copied.  If you have any unusual tags in your XMP then they may not be copied with this technique.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).