janfri / mini_exiftool

This library is a wrapper for the Exiftool command-line application (https://exiftool.org) written by Phil Harvey. It provides the full power of Exiftool to Ruby: reading and writing of EXIF-data, IPTC-data and XMP-data. Branch master is for actual development and branch compatibility-version is for compatibility with Ruby 1.8 and exiftool versions prior 7.65.
GNU Lesser General Public License v2.1
213 stars 52 forks source link

Attach back the metadata to its original file #23

Closed shilpi230 closed 8 years ago

shilpi230 commented 9 years ago

I extracted the metadata in xmp format from some jpeg and raw images now i need to attach that in some different file. How can i do that? I am able to do the same thing with ICC format with png images but its not working with jpeg images.

janfri commented 9 years ago

How would you do this with the exiftool command-line application?

shilpi230 commented 9 years ago

Extract the icc color profile of original image and attach it with whatever file with same mime type again using icc profile.

janfri commented 9 years ago

I have not much time at the moment. Could you give me please an example of command line arguments for exiftool to do this?

shilpi230 commented 9 years ago

yeah sure or if you can tell me where can i edit the code. I can include it :)

janfri commented 9 years ago

No I don't mean mini_exiftool I mean the exiftool command-line application from Phil Harvey which uses mini_exiftool. I don't have the time to read all the documentation how to solve your requirements with exiftool.

shilpi230 commented 9 years ago

first i am checking whether image has icc profile embedded or not if it is not then extract it form exiftool -icc_profile -b -w icc filename then attach it to some other image with exiftool '-ICC_Profile<=%d%f.icc' same_filename

shilpi230 commented 9 years ago

With xmp format exiftool -Tagsfromfile filename out.xmp and then attach it back with this command exiftool -TagsFromFile out.mp '-xmp:all<all' filename

janfri commented 9 years ago

To reattach you could try this with mini_exiftool:

photo = MiniExiftool.new('filename')
photo.copy_tags_from('out.xmp', ['all'])

But mini_exiftool is not designed to do such things. Maybe we could implement this with https://github.com/janfri/multi_exiftool my newer approach of a wrapper for exiftool.

So if the code above doesn't work it would be the best at the moment to do it on a direct way

system "exiftool -icc_profile -b -w icc filename"
system "exiftool '-ICC_Profile<=%d%f.icc' same_filename"
# or
system "exiftool -Tagsfromfile filename out.xmp"
system "exiftool -TagsFromFile out.xmp '-xmp:all<all' filename"

But be aware, you are responsible of handling errors.

shilpi230 commented 9 years ago

Okay sure i will try my best :)