High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(mobile): stop long images squishing on android (#32213)
Santo Shakil135aba5d820d
diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/images/LocalImagesImpl.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/images/LocalImagesImpl.ktindex b3cbc033c9..c89352103a 100644--- a/mobile/android/app/src/main/kotlin/app/alextran/immich/images/LocalImagesImpl.kt+++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/images/LocalImagesImpl.kt@@ -33,17 +33,21 @@ data class Request(val callback: (Result<Map<String, Long>?>) -> Unit)+// Impeller shrinks each side to the GPU texture limit on its own, which squishes long images.+const val MAX_PIXEL_SIZE = 16384+/** Set [exactSize] to decode at the smallest size that covers [target] without upscaling. */@RequiresApi(Build.VERSION_CODES.Q)inline fun ImageDecoder.Source.decodeBitmap(target: Size = Size(0, 0), exactSize: Boolean = false): Bitmap {return ImageDecoder.decodeBitmap(this) { decoder, info, _ ->+ var scale = 1.0if (target.width > 0 && target.height > 0) {if (exactSize) {val fillScale = max(target.width.toDouble() / info.size.width,target.height.toDouble() / info.size.height)- val scale = min(1.0, fillScale)+ scale = min(1.0, fillScale)if (scale < 1) {val width = ceil(info.size.width * scale).toInt()val height = ceil(info.size.height * scale).toInt()@@ -54,8 +58,16 @@ inline fun ImageDecoder.Source.decodeBitmap(target: Size = Size(0, 0), exactSize} else {val sample = max(1, min(info.size.width / target.width, info.size.height / target.height))decoder.setTargetSampleSize(sample)+ scale = 1.0 / sample}}+ val longSide = max(info.size.width, info.size.height)+ if (longSide * scale > MAX_PIXEL_SIZE) {+ val bound = MAX_PIXEL_SIZE.toDouble() / longSide+ val width = max(1, (info.size.width * bound).roundToInt())+ val height = max(1, (info.size.height * bound).roundToInt())+ decoder.setTargetSize(width, height)+ }decoder.allocator = ImageDecoder.ALLOCATOR_SOFTWAREdecoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB))}