Page 1 of 1

Retaining EXIF after composite operation

Posted: 2008-11-03T05:20:55-07:00
by gaspako
I use this (taken from IM resize usage page)

Code: Select all

 convert src.jpg -resize 720x480 -size 720x480 xc:white +swap -gravity center -composite out.jpg
to get this:
Image
(resized portrait source into the landscape output where unused area is filled with white)

The problem I have with this procedure is that the output jpeg does not retain the EXIF info from the source image.
Is there a way to tell IM to transfer EXIF data from the source to the output image?
Or, is there another way to achieve the above resize effect while keeping the EXIF data in the output?

Re: Retaining EXIF after composite operation

Posted: 2008-11-03T11:02:47-07:00
by fmw42
gaspako wrote:I use this (taken from IM resize usage page)

Code: Select all

 convert src.jpg -resize 720x480 -size 720x480 xc:white +swap -gravity center -composite out.jpg
to get this:
Image
(resized portrait source into the landscape output where unused area is filled with white)

The problem I have with this procedure is that the output jpeg does not retain the EXIF info from the source image.
Is there a way to tell IM to transfer EXIF data from the source to the output image?
Or, is there another way to achieve the above resize effect while keeping the EXIF data in the output?
I know nothing about transfer of EXIF data, but doubt any system will transfer that info after processing the image to make it smaller and insert it into another image background, etc, because the result is no longer the same image. What if I were to mosaic 100 images together? What EXIF data would you expect in the result? There may be tools that will let you copy the EXIF data from one image and then insert it into another image. You may want to do a Google search. I will stand corrected, if one of the IM teams says otherwise.

But as for your processing, an easier way is to resize the image and then pad it out with background color:

convert src.jpg -resize 720x480 -background white -gravity center -extent 720x480 out.jpg

Re: Retaining EXIF after composite operation

Posted: 2008-11-03T14:52:46-07:00
by gaspako
Thanks for your suggestion on the resize.
It works the way I need and the output image keeps all the EXIF data - except for the size, of course. :D

Re: Retaining EXIF after composite operation

Posted: 2008-11-03T16:30:16-07:00
by anthony
The -extent will solve the problem.

However as a FYI this is what is actually going on.

When IM Alpha Composes two images. the meta-data for the image (the EXIF info, comments, labels, and other profiles, are taken from the destination image. that is the destination image is modified by the given source or overlay image.

In the above command the destination image (thanks to the +swap) is a blank white canvas! As such it has very little meta-data. There is little you can do about this as the final image size (what you are wanting from the compose) also comes from the destination image!!!

On the other hand -extent modifies the original image, and as such the meta-data of the original image is preserved, including the EXIF information.

The '-border -crop' method which is also on the IM Examples thumbnails page, will also preserve the meta-data and can be used for IM versions which are too old for the faster -extent method.

Re: Retaining EXIF after composite operation

Posted: 2008-11-04T01:26:52-07:00
by gaspako
Yes, -extent did the trick, thank you.