[Image-SIG] Support for EXIF in PIL

Chris Barker Chris.Barker at noaa.gov
Mon Mar 22 05:57:32 EST 2004

Guillaume Sauzon wrote:
> I want to rotate on the fly some pictures. They are JPEG containing EXIF 
> data. If I do it with PIL, I loose the EXIF header. I tried to 
> reconstruct it in the end pictures, but it doesn't work. I guess JFIF 
> and EXIF are somehow incompatible.
> Is there a way to keep this header ?
> Any ideas ?

In addtion to this problem, if you use PIL to rotate a jpeg, it is 
uncompressing and then re-compressing the jpeg. As jpeg is a lossy 
format, you degrade the image a little by doing this.

I'd suggest using one of the versions of jpegtools. Look for:

jpegtran (lossless rotation of images)
jpegcrop (the above, plus lossless cropping)

They both can keep your EXIF data as well. One or both of these is 
likely to be installed already on a Linux system, and I'm pretty sure 
they are available for Windows and other systems as well.

I'd love to wrap jpegcrop up and make a python tool out of it, but at 
the moment, I'm just using it as a system call.


Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the Image-SIG mailing list