From 2ad9a655087910c4e9a0d9e19db572e2f458c7e0 Mon Sep 17 00:00:00 2001 From: MaqsudMallick Date: Fri, 7 Aug 2026 00:32:03 +0530 Subject: [PATCH] remove dimension change gating for bitmap orientation Signed-off-by: MaqsudMallick --- .../owncloud/android/utils/BitmapUtils.java | 47 +------------------ 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/utils/BitmapUtils.java b/app/src/main/java/com/owncloud/android/utils/BitmapUtils.java index 064fd73d5e78..48f46f35f9be 100644 --- a/app/src/main/java/com/owncloud/android/utils/BitmapUtils.java +++ b/app/src/main/java/com/owncloud/android/utils/BitmapUtils.java @@ -109,14 +109,9 @@ public static Bitmap retrieveBitmapFromFile(String storagePath, int minWidth, in var scaledWidth = (int) (originalWidth * scaleFactor); var scaledHeight = (int) (originalHeight * scaleFactor); - var shouldRotate = detectRotateImage(storagePath); var result = decodeSampledBitmapFromFile(storagePath, scaledWidth, scaledHeight); - if (shouldRotate) { - int orientation = getExifOrientation(storagePath); - return BitmapExtensionsKt.rotateBitmapViaExif(result, orientation); - } else { - return result; - } + int orientation = getExifOrientation(storagePath); + return BitmapExtensionsKt.rotateBitmapViaExif(result, orientation); } /** * Calculates a proper value for options.inSampleSize in order to decode a Bitmap minimizing the memory overload and @@ -165,44 +160,6 @@ public static Bitmap scaleBitmap(Bitmap bitmap, float px, int width, int height, return Bitmap.createScaledBitmap(bitmap, w, h, true); } - /** - * Detect if Image will be rotated according to EXIF orientation. Cf. http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/ - * - * @param storagePath Path to source file of bitmap. Needed for EXIF information. - * @return true if image's orientation determines it will be rotated to where height and width change - */ - public static boolean detectRotateImage(String storagePath) { - try { - ExifInterface exifInterface = new ExifInterface(storagePath); - int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); - - if (orientation != ExifInterface.ORIENTATION_NORMAL) { - switch (orientation) { - // 5 - case ExifInterface.ORIENTATION_TRANSPOSE: { - return true; - } - // 6 - case ExifInterface.ORIENTATION_ROTATE_90: { - return true; - } - // 7 - case ExifInterface.ORIENTATION_TRANSVERSE: { - return true; - } - // 8 - case ExifInterface.ORIENTATION_ROTATE_270: { - return true; - } - } - } - } - catch (Exception exception) { - Log_OC.e("BitmapUtil", "Could not read orientation at: " + storagePath); - } - return false; - } - public static int[] getImageResolution(String srcPath) { Options options = new Options(); options.inJustDecodeBounds = true;