SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.38k stars 317 forks source link

Preserve EXIF data when using resize_source #397

Open nuschk opened 8 years ago

nuschk commented 8 years ago

We're using the (awesome) resize_source option to limit user provided images to a reasonable size when uploading. Our options are:

`{'size': (1400, 1400), 'crop': False, 'upscale': False, 'quality': 90}``

Now I've noticed that all EXIF data is lost in the process. Would it be possible to fix this behavior, and would that even be desirable? Unfortunately, I haven't read the source very intimately, but I'd be willing to provide the PR if it's feasible.

SmileyChris commented 8 years ago

I'm not sure you can keep the exif data. PIL loses this data as soon as it transforms the image. What's the issue with losing this data - is it something fundamental like rotation?

nuschk commented 8 years ago

Nothing fundamental, no. I think PIL is already applying orientation info correctly when resizing.

It's just that we would like to look up a few things way after the images have been uploaded by the user (GPS coordinates for example). I'm currently doing it by storing the EXIF data in a separate json field before the image is passed to the ThumbnailerImageField, which is an ok solution for me.

If that's the first time this request came up, it probably means it's really an edge case, though.

jrief commented 8 years ago

@nuschk I'm quite happy the PIL removes EXIF data. It can contain information, I often do not want to expose (for instance camera type, GPS coordinates, etc.). You are further encouraged to reduce the size of images using tools such jpegoptim or optipng. They would remove that information anyway.

nuschk commented 8 years ago

Yeah, that's a use case, too, I suppose. And, I'm completely fine that I don't have any infos on the thumbnails. I'm just referring to the original image, which, I presume, will keep the EXIF data when I don't use resize_option at all. So, the behavior is not terribly consistent...

But, again, I can see that mine is a very special view on the matter and that it doesn't apply for most people.