Skip to content

Editing activity rotate: Exif only rotation for imperfect images, and Jpegtran physical rotation for perfect images - #6957

Draft
rovertrack wants to merge 3 commits into
commons-app:mainfrom
rovertrack:rotate
Draft

Editing activity rotate: Exif only rotation for imperfect images, and Jpegtran physical rotation for perfect images#6957
rovertrack wants to merge 3 commits into
commons-app:mainfrom
rovertrack:rotate

Conversation

@rovertrack

@rovertrack rovertrack commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Description (required)

What changes did you make and why?

  • updated ajpegtran version which has the trim update.
  • added a guard which checks for perfectness of image and if prefect uses jpegtran rotation or uses custom exif tag writer RandomAccessFileExifWriter to updated exif tags for exif only rotation.
  • updated tests
    Tests performed (required)
  • TransformImageTest.kt

Screenshots (for UI changes only)

Demo for imperfect images- Exif only rotation

Before rotating in Commons app

IMG_20260831_013304

After rotating 90° in Commons app

IMG_20260831_013220

Demo for perfect images - Jpegtran physical rotation

Before rotating in Commons app

IMG_20260831_013146

After rotating in Commons app

IMG_20260831_013122

Editing activity rotate: Exif only rotation for imperfect images, and Jpegtran physical rotation for perfect images
val rotated = vm.rotateImage(file, relativeRotation, applicationContext.cacheDir)
imageUri = rotated.absolutePath
} else {
// EXIF-only rotation for imperfect images.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After an EXIF-only rotation the Jpegtran session isn't initialized again, so it looks like any crop that follows would target the un-rotated image. Have you tested the rotate -> crop case?

@github-actions

Copy link
Copy Markdown

✅ Generated APK variants!

@rovertrack
rovertrack marked this pull request as draft August 31, 2026 16:10
@rovertrack

Copy link
Copy Markdown
Contributor Author

@nicolas-raoul as @nonani suggested there is a bug with the current implementation, more importantly one thing i found out was that jpegtran doesn't take into account the Exif orientation before applying edits. so making it exif orientation aware before applying transformation is the good solution.
what do you think?

@nicolas-raoul

Copy link
Copy Markdown
Member

Do we have example images for these cases?
It would be convenient to reproduce any issue.

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.

When rotating, ajpegtran sometimes reduces resolution

3 participants