From 35372831dc020868465086d66d7de08fcb4cf006 Mon Sep 17 00:00:00 2001 From: Jan Nowakowski Date: Thu, 25 Apr 2024 11:47:25 +0200 Subject: [PATCH] fix: check if image is rotated before cropping --- .../AvatarCropModal/AvatarCropModal.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/AvatarCropModal/AvatarCropModal.tsx b/src/components/AvatarCropModal/AvatarCropModal.tsx index dcec2e14a9e7f..d7fc370d1ae46 100644 --- a/src/components/AvatarCropModal/AvatarCropModal.tsx +++ b/src/components/AvatarCropModal/AvatarCropModal.tsx @@ -119,10 +119,17 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose if (!imageUri) { return; } - ImageSize.getSize(imageUri).then(({width, height}) => { - // We need to have image sizes in shared values to properly calculate position/size/animation - originalImageHeight.value = height; - originalImageWidth.value = width; + // We need to have image sizes in shared values to properly calculate position/size/animation + ImageSize.getSize(imageUri).then(({width, height, rotation: orginalRotation}) => { + // On Android devices ImageSize library returns also rotation parameter. + if (orginalRotation === 90 || orginalRotation === 270) { + originalImageHeight.value = width; + originalImageWidth.value = height; + } else { + originalImageHeight.value = height; + originalImageWidth.value = width; + } + setIsImageInitialized(true); // Because the reanimated library has some internal optimizations,