Skip to content

Unexpected rotation on saving a JPEG with orientation exif #183

Closed
@kitsunde

Description

Activity

d-schmidt

d-schmidt commented on Apr 10, 2013

@d-schmidt
Contributor

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

wiredfool commented on Apr 10, 2013

@wiredfool
Member

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

d-schmidt commented on Apr 11, 2013

@d-schmidt
Contributor

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

kitsunde commented on Apr 11, 2013

@kitsunde
Author

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

d-schmidt commented on Apr 11, 2013

@d-schmidt
Contributor

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

aclark4life commented on May 11, 2013

@aclark4life
Member

@CelC Thanks! (for reporting here and upstream)

d-schmidt

d-schmidt commented on May 13, 2013

@d-schmidt
Contributor

Imho I would flag this as closed/wont fix.

added a commit that references this issue on Jan 30, 2014
added a commit that references this issue on Sep 24, 2023
e28e44c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wiredfool@kitsunde@aclark4life@d-schmidt

        Issue actions

          Unexpected rotation on saving a JPEG with orientation exif · Issue #183 · python-pillow/Pillow