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

Paul Moore p.f.moore at gmail.com
Sun Jun 5 16:07:05 CEST 2005

On 6/5/05, Terry Carroll <carroll at tjc.com> wrote:
> Can anyone tell me if it's fairly easy to copy a JPEG file's EXIF data to
> another file.  Even better would be if this is doable in PIL.
> My basic problem:
> I've written a small program that reads a JPEG image in PIL, and creates a
> copy that is slightly modified (it overlays the image with a datestamp
> taken from the EXIF data), and saves it as a new file.  It all works
> swimmingly well, except that the ne file has no EXIF data.  I'd like to
> copy the original image's EXIF data to the new image.

You can *read* EXIF information via the _getexif() method of the
image. Use the KEYS dictionary in the ExifTags module to map numeric
keys to friendly names. For example,

>>> d = dict((ExifTags.TAGS[k], v) for k, v in im._getexif().items())
>>> d['DateTimeOriginal']
'2002:08:07 17:07:59'

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

Hope this helps (a bit)

More information about the Image-SIG mailing list