[Image-SIG] Copying EXIF data from one file or PIL image to another?

Terry Carroll carroll at tjc.com
Mon Jun 6 02:46:46 CEST 2005

On Sun, 5 Jun 2005, Richard Townsend wrote:

> Not sure about PIL, but Gene Cash has a Python module for handling EXIF 
> data:
> http://home.cfl.rr.com/genecash/digital_camera.html

Thanks, Richard.  I'm already using that -- that's how I'm getting the 
EXIF data -- but it's read-only, there's no way to take its data and write 
to another JPEG file.

On Sun, 5 Jun 2005, Paul Moore wrote:

> You can *read* EXIF information via the _getexif() method of the
> image....

> [example snipped]

> Unfortunately, I don't know of a way to *write* EXIF information with
> PIL.

Yeah, that's what it looks like to me.  I tried 

     im0.app = im.app

where im is the source image amd im0 is my destination image; that adds 
the appropriate EXIF data to the PIL Image object, but it doesn't get 
written out to the file when I do an im0.save().

This is still helpful information, though.  I had no idea that PIL
supported EXIF, and I'd rather use PIL's support than load in Gene Cash's
module: one less dependancy.

On Sun, 5 Jun 2005, Max Erickson wrote:

> Jhead should be able to transfer the exif information:
> http://www.sentex.net/~mwandel/jhead/
> Alternatively, see:
> http://mail.python.org/pipermail/image-sig/2004-September/002931.html
> for a patch that adds support for writing raw exif headers to pil.

Thanks.  I think I'll go with JHead.  This program is mostly for personal 
use, but I may have one or two friends who may find it useful, too.  I can 
put in a "Preserve EXIF (requires JHEAD)" checkbox, so that it's useful 
w/o it.  It's probably easier to copy JHead along with my program than it 
is to patch PIL.

Thanks to all responses.

More information about the Image-SIG mailing list