-
Notifications
You must be signed in to change notification settings - Fork 28
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
Wrong image rotation/orientation applied to output #23
Comments
Hmm... so this is interesting. So here's what I found:
I tried to repro this with my own iPad. I took photos in all 4 orientations (again, in human terms, I know there's actually 8 orientations, because of course there is). All of those photos had Now, the fact that your image is missing most of its exif data is interesting. How did you generate this image. It doesn't seem to just be a normal iPhone image. Did you use a novel way of getting this image from your iPhone to your computer? Did you purposefully strip the exif data (I get it, it can have GPS data in there and whatnot, you wouldn't want to share that on the internet)? If so, how did you do that? Essentially, there are two options that we need to narrow down:
|
The image attached is just a default demo image that Apple provides with the iOS Simulators. I did not attach the images I made due to privacy reasons. I was testing earlier today and I could reproduce it again - though not every time. I took a bunch of images with my iPhone and converted them all. It seems to happen completely randomly. If you want I can send you the original iPhone images (RAW, including all EXIF data) in private for debugging purposes. |
Haha, it's very Apple to not follow specs and make it everyone else's problem. Feel free to email the images to [email protected]. You can always turn off saving gps data to images before taking test photos... if you want... I promise I won't share them myself. |
Sent. :) |
Well... this is fun. For posterity, I am reading the exif information using For posterity, I tested these images in all the apps I mentioned before, and I see the same thing. The image with less exif data renders sideways in all of them. It even renders sideways in the OneDrive preview that you sent me (which... maybe no one is surprised, they all use But, of course, I promised fun. All 3 of the images have the Anyway, I digress. I have no idea why your images are different. Again, that seems like an Apple problem (why would you write two different images Apple??). Did you know if you did something subtle or different when taking these? Taking consecutive images super fast? Some king of burst mode? Does Apple's camera even have burst mode? I mostly want to be able to take repro images of my own. |
Of course, after I did all that, I simply went to the source and found that I was on the right track though. It looks like in the HEIF spec, EXIF data (including orientation) is considered informational and should not change how images are rendered (in contrast to JPEG, where orientation is expected to be applied at render-time to correct the image). HEIF has a specific way to define complex transformations, and an image is considered malformed if it doesn't have those (or does not include any one specific transformation that a thinking human would go "hey, that's wrong"). It seems to happen with tiled images? Which, that third image is tiled while the first two are not. In the words of that bug... "Yes, blaming someone else... is the way to go :-)" |
Alright got it, seems like Apple is ruining the show.. What do you recommend as a workaround? The one in the issue you mentioned? |
That's your call really. Rotating the jpeg is trivial, it's detecting that there's a problem that is the hard part. If you are just converting them for personal use and it is not a lot of images, you can just look at your results and fix the ones didn't work out. Pretty much every photo app nowadays supports rotation. If you are wanting to automate something for general use, that's when it gets hard. Technically, as Apple has written the file, it is not supposed to be rotated. And who's to say that the thing Apple is doing wrong when generating this completely legal image is not something that some other software does correctly and expect it to work as intended following the spec 🤷♀️.
When you get a jpeg, you could write exif data to it? Or use I think no one is solving this one in an automated way because Apple's bug can also be someone else actually meaning to do that same thing but doing it correctly, in which case a "fix" actually breaks the image. Apple's answer would be to only view photos taken on an Apple camera and only view them on an Apple device. |
Hi,
converting a HEIC image shot on an iPhone 13 to either a JPEG or PNG results into the image being flipped (wrongly rotated) for some images.
Looking at the EXIF data of the converted JPEG it looks like it just sets the orientation to 3 for every image.
I'll also attach the test HEIC file if you want to debug it (it's zipped because Github does not allow HEIC files)
heic.heic.zip
The text was updated successfully, but these errors were encountered: