1

Exiv2 seems to work quite well with batch operations by keeping any generated derivative files the same root filename with an different extension.

My mission is to draw the meta information from a master jpg file and then apply it to several existing smaller versions of the file. I have...

  Photo1.jpg        - contains meta information
  thumb_Photo1.jpg  - no meta information
  sample_Photo1.jpg - no meta information

Right now I use exiv2 to pull the meta information out of Photo1.jpg resulting in a file...

  Photo1.xml

What I would like to do next is apply this metadata to the thumbnail and sample files. With Exiv2 I cannot find a way to make it function with anything other than files with corresponding base names. Thus I can't apply Photo1.xml to thumb_Photo1.jpg, only Photo1.jpg.

For the moment I get around this by making copies of the XML file leaving me with this...

  Photo1.jpg        - contains meta information
  Photo1.xml        - derived from Photo1.jpg
  thumb_Photo1.jpg  - no meta information
  thumb_Photo1.xml  - copy of Photo1.xml
  sample_Photo1.jpg - no meta information
  sample_Photo1.xml - copy of Photo1.xml

With this done I then can run exiv2 to add tags to the thumb and sample jpegs. Afterwards I delete the XML files, leaving me with three files all tagged identically.

While the above works very well, I'm wondering if I have missed an exiv2 option buried deep in the documentation that allows one to tag a JPEG from an XML file of a different base name.

  • 1
    Um... wouldn't exiftool -AllTagsFromFile=Photo1.jpg *_Photo1.jpg do what you want with a single command? – inkista Jan 6 '16 at 21:22
  • @inkista you beat me to the punch. – scottbb Jan 6 '16 at 21:32
  • 1
    @scottbb but not to an answer. :) – inkista Jan 6 '16 at 22:44
  • exittool is on my list. I just wanted to exhaust trying to use exiv2 first. Thanks much for the input. – JSH Jan 7 '16 at 22:03
2

exiv2 seems to really prefer keeping the basenames of image files and sidecar/metadata files matched. You could automate (script) the creation/deletion of copying/renaming the metadata files like you have.

However, for what you want to do, I would strongly suggest using exiftool. It follows the unix stream paradigm much more closely. You can do what you want using exiftool with the following command:

> exiftool -TagsFromFile Photo1.jpg *_Photo1.jpg
    2 image files updated

This has the benefit of not needing to create the metadata files as an interim step; it merely copies the data from Photo1.jpg into any file matching the pattern *_Photo1.jpg.

  • Sometime is good to have intermediate file, you can use it as information source in other instruments :) – Romeo Ninov Jan 6 '16 at 21:52
  • @RomeoNinov true, but in this case, when using exiv2, the intermediate files are undesirable and require extra work. Hence the OP's question. =) – scottbb Jan 6 '16 at 21:54
  • One thing I need to be sure of is how well translation from XML to IPTC, etc. work. I found one nit in last night's experimentation where the "Rights" field of the XML wound up empty. Thanks for all the inputs thus far... it's obvious I have posted my question in the right place. – JSH Jan 7 '16 at 22:08
1

Have you try this way:

cat  Photo1.xml | exiv2 -i - thumb_Photo1.jpg

This command will send the content of Photo1.xml to STDOUT and the next command will use it as STDIN and insert it in to thumb_Photo1.jpg file.

P.S. In the man page of exiv2 I see this example:

exiv2 -e{tgt}- filename|xmllint .... | exiv2 -i{tgt}- filename
  • 1
    Thanks Romeo. I will try that this evening. As I understand it, exiv2 doesn't use stdin, but this is a good idea to try regardless. Thanks. – JSH Jan 6 '16 at 21:05
  • 1
    @JSH, if you check the man page of exiv2 you will see example where are used pipes (STDOUT|STDIN). Check my edited answer please – Romeo Ninov Jan 6 '16 at 21:45
  • 2
    @RomeoNinov I think you mean to use cat Photo1.xml | ... instead of echo Photo1.xml | .... Also, this would qualify for "Useless Use of Cat" or "cat abuse". =) Just use stdin redirection: exiv2 -i - thumb_Photo1.jpg < Photo1.xml – scottbb Jan 6 '16 at 22:26
  • 1
    @scottbb, right, my mistake, will correct it :) P.S. I adore cat :D – Romeo Ninov Jan 7 '16 at 3:58
  • 1
    Pipes. Yes I did miss that. Will give it a try tonight. Thanks. – JSH Jan 7 '16 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.