Fixed photos being rotated when uploaded - #88
Conversation
Add a new sample featuring the new Gemini 2.5 Flash image model
Change-Id: Idc680e6afbef7cc7e40fee23a950b216d75d7a27
There was a problem hiding this comment.
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
-
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. ↩
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Thanks for fixing it!
I don't think the androidx.exifinterface import is necessary.
Change-Id: I0abfb36c0515152f6dbb09b185a5b1154e9bf229
For selfies take with my Samsung device, the portrait images showed as landscape. Fixed by taking into account the EXIF rotation data.