Skip to content

Fix #5711 Incorrect rotation in Edit Image while uploading. #5760

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

acemarco1311
Copy link

@acemarco1311 acemarco1311 commented Jun 20, 2024

Description (required)

Fixes #5711. While uploading, when click "Edit Image" and then perform no rotation (click Save, or click Rotate 4 times to get back to the original position and Save), the image will be automatically rotated 90 degrees.

What changes did you make and why?
Change rotateImage() function implementation in edit/TransformImageImpl.kt. When the given degree is not expected (e.g 0), the transformation of the image should be default instead of rotating 90 degree (LLJTran.ROT_90).

Tests performed (required)

Tested on Pixel 8 with API level 35.

Reproduce:

  1. Open app.
  2. Upload image.
  3. Click "Edit Image".
  4. Click "Save" or "Rotate" 4 times so that the image will be in the original position then "Save".

Error Behavior:

error_final.mp4

Expected Behavior:
The image will be shown as original instead of being rotated 90 degree after clicking "Save".

Screenshots (for UI changes only)

expected_final.mp4

@nicolas-raoul
Copy link
Member

Hi Toan,

Would you mind checking whether your change works with all JPGs at https://github.com/recurser/exif-orientation-examples ?

Thanks! 🙂

I feel like different pictures have different properties, and what works for one picture might not work for another.

Idea potentially for another pull request:
It would be great if we had a small repository (could be a Google Drive for now) with the example pictures we encountered so far, if the repository above is not enough. Ideally unit tests would use these pictures (or simpler+smaller JPGs) to check rotation in the UI and in the resulting image output.

@mnalis
Copy link
Contributor

mnalis commented Feb 13, 2025

Yeah, it seems buggy (unless I messed up compilation). I've tried to build this PR against master (beta APK available at https://github.com/mnalis/apps-android-commons/actions/runs/13313689246). There seems to be at least one additional issue:

For example, this image has physical layout correct (landscape), but contains EXIF Orientation : Rotate 90 CW which orients it wrongly (to portrait).

small_Stari_grad_Đurđevac

  • If you look it in gallery, EXIF orientation is applied, and it looks wrong in portrait (but behaviour is correct)
  • If you share it in Commons app, EXIF orientation is applied, and it looks wrong in portrait (but behaviour is correct)
  • but if you press Edit in Commons app, even before any rotate button is pressed, the picture is shown in landscape (so it looks good), but that means that EXIF orientation was ignored, which is wrong behaviour! It should be displayed in portrait too, before user starts to correct it with rotate buttons.
  • also, if you for example rotate by 180, and save, and then press edit again, it will be shown in original non-rotated state. It seems that it completely ignores any existing rotation state of the picture when it is opened for edit.

@mnalis
Copy link
Contributor

mnalis commented Mar 29, 2025

@acemarco1311 do you any idea why the PR does not (fully) solve the rotation issue? Do you intend to continue working on this PR?

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

Successfully merging this pull request may close these issues.

[Bug]: Incorrect rotation shown in "Edit Image"
4 participants