Skip to content

Image Resizing #3162

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 3 commits into
base: master
Choose a base branch
from
Open

Conversation

anandwana001
Copy link
Collaborator

@auto-assign auto-assign bot requested a review from shobhitagarwal1612 June 9, 2025 09:30
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 0% with 33 lines in your changes missing coverage. Please review.

Project coverage is 68.79%. Comparing base (60d4cc3) to head (f7617d9).

Files with missing lines Patch % Lines
.../groundplatform/android/ui/util/RotateUsingExif.kt 0.00% 26 Missing ⚠️
...roundplatform/android/ui/common/BindingAdapters.kt 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3162      +/-   ##
============================================
- Coverage     69.05%   68.79%   -0.27%     
  Complexity     1378     1378              
============================================
  Files           287      287              
  Lines          7146     7174      +28     
  Branches        719      724       +5     
============================================
  Hits           4935     4935              
- Misses         1822     1850      +28     
  Partials        389      389              
Files with missing lines Coverage Δ
...roundplatform/android/ui/common/BindingAdapters.kt 32.14% <0.00%> (-10.72%) ⬇️
.../groundplatform/android/ui/util/RotateUsingExif.kt 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

.transform(RotateUsingExif(uri, view.context))
.into(view)
} catch (exception: OutOfMemoryError) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need a custom message here.

override fun transform(source: Bitmap): Bitmap {
val orientation = getOrientationFromExif(uri)
val rotateDegrees = getRotationDegrees(orientation)
return rotateBitmap(source, rotateDegrees)

val resizedBitmap = resizeBitmapIfNeeded(source, maxWidth, maxHeight)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This single responsibility (see https://en.wikipedia.org/wiki/Single-responsibility_principle) of this transformation is to rotate the image. Having it also resize would be surprising. Instead, create a separate ResizeTransformation and chain the two to achieve the desired result.

Copy link
Collaborator

@gino-m gino-m left a comment

Choose a reason for hiding this comment

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

Please update the title of the PR to describe the user visible effect merging this change will cause. e.g. "Resize photos when showing inline thumbnail to OOM"

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.

Trending crash: Fatal Exception: java.lang.RuntimeException Canvas: trying to draw too large(201326592bytes) bitmap.
3 participants