android, desktop: keep wide images at natural aspect ratio without crashing (#7125)

* android, desktop: keep wide images at natural aspect ratio without crashing

The merged fix clamped the framed image preview's aspect ratio at 2.33,
which prevents the Constraints overflow crash but reshapes every image
wider than 2.33:1 to 2.33:1.

Compute the box height directly (height = w * min(h / w, 2.33f)) instead
of deriving it via Modifier.aspectRatio. Very wide images keep their
natural ratio (no upper clamp) while taller images stay capped at 2.33,
and the overflow-prone width = height * ratio derivation is removed
entirely. This mirrors how the iOS app sizes image previews.

* docs: update wide-image crash plan for natural-ratio fix

* remove comment

---------

Co-authored-by: Evgeny <evgeny@poberezkin.com>
This commit is contained in:
Narasimha-scandEvgeny authored and GitHub committed 2026-07-02 10:48:51 +01:00
1 parent 10958d447d
commit 2c2337b07c
2 files changed
+47 -37

No files matched your search

@@ -176,7 +176,7 @@ fun CIImageView(
.then(
if (!smallView) {
val w = if (previewBitmap.width * 0.97 <= previewBitmap.height) imageViewFullWidth() * 0.75f else DEFAULT_MAX_IMAGE_WIDTH
Modifier.width(w).aspectRatio((previewBitmap.width.toFloat() / previewBitmap.height.toFloat()).coerceIn(1f / 2.33f, 2.33f))
Modifier.width(w).height(w * (previewBitmap.height.toFloat() / previewBitmap.width.toFloat()).coerceAtMost(2.33f))
} else Modifier
)
.desktopModifyBlurredState(!smallView, blurred, showMenu),