New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image.open transposing the image automatically on open? #1188
Comments
While I can see the question you're asking is - why doesn't Pillow automatically rotate the image? - I feel like you're also raising the question - when you open and save an image, should the result be the same as the original, rather than the EXIF data being lost? |
Also, if you're interested in just solving the problem within your own code, http://stackoverflow.com/questions/4228530/pil-thumbnail-is-rotating-my-image/ should have what you're looking for. |
hi! Thanks for your quick response. I should have worded my question better. My use case is as follows: I have an image processing system which processes photos and renders them into sizes for display. The photos could be taken by various devices like cameras etc. When the photo is taken by an iphone in portrait mode, then the photo is marked with the exif rotation tag. We want to process this tag, and rotate the photo to get it back into it's proper orientation before creating the sizes. The SO article you pointed to, that is exactly what we are doing. We read the EXIF tag from the image, and then apply transformation on the image to get it back to it's correct orientation before doing further processing. Now, onto our problems:
|
So you have a error somewhere in your code, not in Pillow, right? If you want, you can show the code and someone can help you. Feroze, let's understand the terminology. As I know, Pillow does not rotate any images. It shows and saves exactly the pixels stored in the original image. You see rotated image not because Pillow rotate it. This is because the image is really stored rotated. Other software (not all, by the way) can show the image in correct orientation if it analyzes a meta information (EXIF). You can keep or discard a meta information while saving back in JPEG. You can manually rotate actual image data and discard rotation information while saving or displaying. You can't keep a meta information while displaying, because |
hi! Thanks for your response. The problem turned out to be bad image metadata in the image. The image was upright, but it's metadata said RightTop (Orientation = 6). So, when I did a Image.open('image.jpg').show() it showed the upright image, and I thought that either PIL, or the show() operation was autocorrecting the image rotation. Turned out not to be the case. But I did notice one issue. I have a collection of images that have this problem. PIL is correctly reporting the orientation of those images. However, when I run jpegexiforient tool from jpeg-tools, it doesnt give me any orientation info. Is JPEG reading the orientation from a different place? OTOH if I take an image with my IPhone with different orientations, the jpegexiforient and PIL/Pillow show the correct value for Orientation EXIF tag. For your help, I have put the images that are showing inconsistent behavior in s3: $ s3t ls s3://feroze/exif/ You can download these using: curl -s http://feroze.s3.amazonaws.com/1.jpg etc. THe 1.jpg through 6.jpg are images that have orientation set to 1 through 6. These images have the correct orientation set. image.jpg is an upright image, but has orientation set to 6. This is the one that had me confused. |
Rereading the last post in this, you seem to be saying that Pillow is actually exhibiting the correct behaviour, and that there isn't a problem? Also, the images that you linked to are no longer accessible. |
I have an image that I took using Iphone in portrait mode. When the iphone stores this image, it stores an Exif Orientation tag with value 6 on the image. This means that the image needs to be rotate left 90deg to get back the original.
Now, I do the following:
expecting to see the original image rotated 90, i.e the way the iphone saved it. but instead I am getting a corrected image.
If I save the image as a different file, and look at it using "eog" which is the image viewer on my ubuntu box, I again get the "corrected" image. If I use "eog" to look at the original image, I see an image rotated 90deg ( as I expect ).
why is Image.open () rotating the image ?
My use case, is that I have an image processing application, and I need to correct the source image orientation depending on the exif tag.
The text was updated successfully, but these errors were encountered: