Skip to content

Fixed photos being rotated when uploaded - #88

Merged
JolandaVerhoef merged 11 commits into
mainfrom
jv/photo-orientation
Sep 1, 2025
Merged

Fixed photos being rotated when uploaded#88
JolandaVerhoef merged 11 commits into
mainfrom
jv/photo-orientation

Conversation

@JolandaVerhoef

Copy link
Copy Markdown
Collaborator

For selfies take with my Samsung device, the portrait images showed as landscape. Fixed by taking into account the EXIF rotation data.

lethargicpanda and others added 7 commits August 27, 2025 10:34
Add a new sample featuring the new Gemini 2.5 Flash image model
Fix the bug for the case where there’s no image returned by the model
Change-Id: Idc680e6afbef7cc7e40fee23a950b216d75d7a27

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Summary of Changes

Hello @JolandaVerhoef, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug where uploaded images, particularly selfies from certain devices, were displayed with incorrect orientation. The changes introduce robust image processing by leveraging EXIF metadata to ensure photos are always shown with their intended rotation, significantly improving the user experience for image uploads.

Highlights

  • Image Rotation Fix: Implemented a solution to correctly display images by reading and applying EXIF orientation data, resolving issues where photos appeared rotated after upload.
  • New Utility Function: Introduced loadBitmapWithCorrectOrientation in BitmapUtils.kt to encapsulate the logic for loading bitmaps and correcting their orientation based on EXIF tags.
  • Dependency Update: Added the androidx.exifinterface library to the project's dependencies to enable reading EXIF metadata from images.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Change-Id: Ie63099f574ef5a789805ef48a46ad47e6c6e13ef

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request correctly identifies and fixes an issue with image orientation by reading EXIF data. The introduction of a utility function for this is a good step. My review focuses on two main points: first, a critical performance issue where a blocking I/O operation is performed on the main thread, which can lead to ANR errors. I've suggested using coroutines to fix this. Second, I've recommended improving the new utility function by using the modern ImageDecoder API, which simplifies the code and aligns with current Android best practices. These changes will improve the app's performance and maintainability.

Change-Id: I2e0a2af16e767beb7e6c549c01a753776e1ffe39

@lethargicpanda lethargicpanda left a comment

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.

Thanks for fixing it!
I don't think the androidx.exifinterface import is necessary.

Comment thread ai-catalog/gradle/libs.versions.toml
Change-Id: I0abfb36c0515152f6dbb09b185a5b1154e9bf229
@JolandaVerhoef
JolandaVerhoef changed the base branch from gemini-image-sample to main August 29, 2025 16:41

@ksemenova ksemenova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@JolandaVerhoef
JolandaVerhoef merged commit eb7f2e1 into main Sep 1, 2025
5 checks passed
@JolandaVerhoef
JolandaVerhoef deleted the jv/photo-orientation branch September 1, 2025 11:20
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.

3 participants