You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
On some images, the 90 degree rotation is not correctly applied (or any other rotation).
To Reproduce
Steps to reproduce the behavior:
In the example app, in function resize put a value of 90 in rotation parameter
Build the example application;
Select an image with a EXIF orientation code = 4 (see explanation below)
Observed behavior
original
result
Expected behavior
original
result
Platform concerned:
Android: ✅
iOS: ✅
Details
Current behavior
Before applying any transformation to the image, the library do two things:
Load the bitmap image = a grid of dots or pixels that forms an image = raw image of the camera sensor
Get the orientation of that image following the EXIF orientation code;
Add the rotation if parameter is specified;
Apply the rotation to the bitmap;
Apply the resizing to the bitmap;
Save the new image.
Problem
We do not handle properly all EXIF Orientation code.
In the case of an Orientation code = 4 (i.e Mirror vertical), the getOrientation method returns 0, which is correct, but we do not apply a vertical flip on the bitmap before applying the desired rotation.
The EXIF Orientation code tells to the device how the image (orientation + flip) should be displayed on the screen (i.e. how the bitmap should be displayed) => more information about each value here
The following array show which EXIF orientation value are & are not properly handled with a rotation of 90°:
Proposition of algorithm
Load the bitmap image = a grid of dots or pixels that forms an image = raw image of the camera sensor
Get the orientation of that image following the EXIF orientation code;
Get the flip (horizontal, vertical or none) of that image following the EXIF orientation code;
Apply the rotation to the bitmap;
Apply the flip to the bitmap;
Apply the rotation if parameter is specified;
Apply the resizing to the bitmap;
Save the new image.
The text was updated successfully, but these errors were encountered:
taboulot
changed the title
WIP - Apply correct rotation depending on EXIF orientation code
Apply correct rotation depending on EXIF orientation code
Apr 30, 2024
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug
On some images, the 90 degree rotation is not correctly applied (or any other rotation).
To Reproduce
Steps to reproduce the behavior:
resize
put a value of90
in rotation parameterObserved behavior
Expected behavior
Platform concerned:
Details
Current behavior
Before applying any transformation to the image, the library do two things:
Problem
We do not handle properly all EXIF Orientation code.
In the case of an Orientation code = 4 (i.e Mirror vertical), the getOrientation method returns 0, which is correct, but we do not apply a vertical flip on the bitmap before applying the desired rotation.
The EXIF Orientation code tells to the device how the image (orientation + flip) should be displayed on the screen (i.e. how the bitmap should be displayed) => more information about each value here
The following array show which EXIF orientation value are & are not properly handled with a rotation of 90°:
![image](https://private-user-images.githubusercontent.com/9041221/326848946-93d4fc1b-0481-40e8-a0cf-1ab52c894fb6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzODgwNTQsIm5iZiI6MTcyMjM4Nzc1NCwicGF0aCI6Ii85MDQxMjIxLzMyNjg0ODk0Ni05M2Q0ZmMxYi0wNDgxLTQwZTgtYTBjZi0xYWI1MmM4OTRmYjYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDczMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MzFUMDEwMjM0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OWYwYmEzY2I0OWEyYTBiMmE3MGUwZjEzNWM5MzVhMDllMzQxODBiMjhlZDY3YjQxMDJlMDNjZTc2NmEzMjU0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.fMK_fbpJ6Y-wCky1sr1Y5cpKRJfTbMsJGs5oRDjsMzY)
Proposition of algorithm
The text was updated successfully, but these errors were encountered: