Closed
Description
I've posted this issue upstream to PIL, here: https://bitbucket.org/effbot/pil-2009-raclette/issue/33/unexpected-rotation-on-saving-a-jpeg-with
I've posted this issue upstream to PIL, here: https://bitbucket.org/effbot/pil-2009-raclette/issue/33/unexpected-rotation-on-saving-a-jpeg-with
Activity
d-schmidt commentedon Apr 10, 2013
I've implemented some code to maintain the exif data already, you can just use it.
edit: I mentioned how to use it here :#36 (comment)
wiredfool commentedon Apr 10, 2013
Should the jpeg save exif info by default? It would be new, as apparently pil didn't save exif info at all until the patch from #36
d-schmidt commentedon Apr 11, 2013
Imho opt-in is better than opt-out. You don't save the original jpeg, you load the image data and save it as a new image. It is the same as transparency for most of the images. You have to choose to save it.
Exif is very bulky and big and you would have to change existing code. You wouldn't want a 1kb thumbnail containing 60kb exif data.
kitsunde commentedon Apr 11, 2013
If it's opt out by default it means that PIL strips exit data, then at the very least it should rotate the image to the correct position when striping orientation.
Personally I think it's a bit dangerous to strip image data like this, one can imagine doing a large scale image transform, and not realizing loosing all the meta data until months down the line. Like in this case some percentage of the images would be rotated wrongly and would need manual intervention, luckily for us we deal with short term storage of image data so I don't need to do that in this case.
In practice though I only care about the rotation at the moment. Handling all exif issues or not seem like a separate issue.
On 11 apr 2013, at 18:25, David Schmidt notifications@github.com wrote:
d-schmidt commentedon Apr 11, 2013
PIL can't properly read/analyze the exif data and find the rotation at the moment. The only thing it can do is copy the whole bulk of binary data and write it into a new jpeg file. Analyzing EXIF is a pain and there are already other python modules out there capable to do so.
Opt-out means, it would copy all exif data by default and you would have to disable it if you don't want it. Opt-in means it is capable to copy the data but you need to tell it to do so. Opt-in is currently included, you could use that.
Pillow doesn't strip data, it ignores it, it doesn't know there is data. When saving an image it loses every knowledge of the source file. It doesn't matter how the image got generated or loaded, it just saves the plain image the way you wish it to do.
Pillow is not a one-line image converter, it is a good library with all the tools to create one yourself.
Our converter uses jhead combined with jpegtran to rotate the images losslessly prior creating the thumbnails with pillow.
aclark4life commentedon May 11, 2013
@CelC Thanks! (for reporting here and upstream)
d-schmidt commentedon May 13, 2013
Imho I would flag this as closed/wont fix.
Fix image orientation for PIL engine
Merge pull request python-pillow#183 from radarhere/travis
Fix image orientation for PIL engine
Fix image orientation for PIL engine