Skip to content
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

Apply correct rotation depending on EXIF orientation code #402

Open
taboulot opened this issue Apr 30, 2024 · 6 comments
Open

Apply correct rotation depending on EXIF orientation code #402

taboulot opened this issue Apr 30, 2024 · 6 comments
Labels

Comments

@taboulot
Copy link
Contributor

taboulot commented Apr 30, 2024

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:

  1. In the example app, in function resize put a value of 90 in rotation parameter
  2. Build the example application;
  3. Select an image with a EXIF orientation code = 4 (see explanation below)

Observed behavior

original result
image image

Expected behavior

original result
image image

Platform concerned:

  • Android: ✅
  • iOS: ✅

Details

Current behavior

Before applying any transformation to the image, the library do two things:

  1. Load the bitmap image = a grid of dots or pixels that forms an image = raw image of the camera sensor
  2. Get the orientation of that image following the EXIF orientation code;
  3. Add the rotation if parameter is specified;
  4. Apply the rotation to the bitmap;
  5. Apply the resizing to the bitmap;
  6. 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°:
image

Proposition of algorithm

  1. Load the bitmap image = a grid of dots or pixels that forms an image = raw image of the camera sensor
  2. Get the orientation of that image following the EXIF orientation code;
  3. Get the flip (horizontal, vertical or none) of that image following the EXIF orientation code;
  4. Apply the rotation to the bitmap;
  5. Apply the flip to the bitmap;
  6. Apply the rotation if parameter is specified;
  7. Apply the resizing to the bitmap;
  8. Save the new image.
@taboulot taboulot changed the title WIP - Apply correct rotation depending on EXIF orientation code Apply correct rotation depending on EXIF orientation code Apr 30, 2024
@taboulot
Copy link
Contributor Author

I do not have at the moment any time to implement it. Any help is welcome.

@retyui
Copy link

retyui commented Apr 30, 2024

you can find more images
with Exif for testing https://github.com/recurser/exif-orientation-examples

Copy link

stale bot commented Jun 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.

@stale stale bot added the wontfix label Jun 30, 2024
Copy link

stale bot commented Jul 7, 2024

This issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Jul 7, 2024
@genaris
Copy link

genaris commented Sep 16, 2024

Is this problem solved? Not working for me in 3.0.10.

@taboulot taboulot added bug and removed wontfix labels Sep 17, 2024
@taboulot taboulot reopened this Sep 17, 2024
@taboulot
Copy link
Contributor Author

@genaris it should be fix on android but there is still the problem on iOS. I reopen it. Any contribution is welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants