disintegration / imaging

Imaging is a simple image processing package for Go
MIT License
5.3k stars 443 forks source link

Image orientation issue with latest iOS 13.1.2 "Choose Image Size" feature #104

Closed Alexn117 closed 5 years ago

Alexn117 commented 5 years ago

In iOS 13 when uploading an image you are prompted with the option to "Choose Image Size" on the selected image, to reduce the size of the original file for upload. This is optional, and you can upload the original large file if you wish.

When uploading the original image file, without using this feature, the image ends up being rotated properly by use of:

i, err := imaging.Decode(file, imaging.AutoOrientation(true))
if err != nil {
    return err
}

But, if you choose to resize the image to "Large", "Medium", or "Small" (using the "Choose Image Size" iOS feature), the uploaded image does not correct the orientation and remains rotated.

I believe iOS is doing something to the image uploaded with "Choose Image Size", that Disintegration is not taking account of. Perhaps there are additional computations and checks that need to be ran to properly adjust the orientation data of these images.

EDIT: test image below.

disintegration commented 5 years ago

Thank you for the report!

Could you please attach an example image so I can reproduce the issue?

Alexn117 commented 5 years ago

Sure! See the original post above.

disintegration commented 5 years ago

I've downloaded the test image and attached it to this comment with the “small size” setting using iOS 13.1.2:

C16B14C4-047F-4E80-8905-5B0EB13E02A1

disintegration commented 5 years ago

The exif command-line utility reports "Right-top" orientation for the original image and "Top-left" for the small-size-uploaded one. It looks like the original orientation tag is lost for some reason when using this option.

I also tried to open these images using GIMP and the Gnome Image Viewer. Both of them display the first image correctly while the second one is displayed rotated.

Alexn117 commented 5 years ago

Yeah I'm seeing that iOS is changing the original orientation tag on the small-sized version. It is setting it to Orientation: 1 (Normal). While the original image had Orientation: 6 (Rotated 90° CCW). I'm seeing this data if you open each image with Preview on macOS > Tools > Show Inspector > General tab. This website explains those numbers:

https://www.impulseadventure.com/photo/exif-orientation.html

I take it that since iOS changes the original orientation tag, there's no way of solving this? Have to report to Apple and wait for iOS to preserve the original orientation tag?

disintegration commented 5 years ago

I've just conducted one more test just to ensure that github uploader isn't modying the image data. I've created a simple server with an upload form and used it to save the raw uploaded bytes to a file.

The result is the same as before: the uploaded image has the wrong orientation tag and the iOS software itself displays it rotated. Looks like it's an iOS issue.

disintegration commented 5 years ago

I'm closing the issue, feel free to reopen if I missed something.

Lelelo1 commented 4 years ago

I also experienced this issue. I made a [cmd shift 4] screen shot for each original iPhone photo I intended to upload. The screenshots are uploaded correctly.

propagandaCreative commented 4 years ago

I'm experiencing this issue on a completely unrelated app I'm writing - anyone found any solutions to this?

tomislavsantek commented 4 years ago

I'm afraid not. The orientation information is lost (apple device sets the orientation tag to 1 - normal), so there's no way to handle this right now :(

SudoPlz commented 3 years ago

That's also our experience.. I think it's a bug on the Apple side..