Skip to content

Commit 96bd3b0

Browse files
author
Hayata Suenaga
authored
Merge pull request #40971 from software-mansion-labs/fix-image-cropping
fix: check if image is rotated before cropping
2 parents 71060e5 + 2fc6aad commit 96bd3b0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/components/AvatarCropModal/AvatarCropModal.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,17 @@ function AvatarCropModal({imageUri = '', imageName = '', imageType = '', onClose
119119
if (!imageUri) {
120120
return;
121121
}
122-
ImageSize.getSize(imageUri).then(({width, height}) => {
123-
// We need to have image sizes in shared values to properly calculate position/size/animation
124-
originalImageHeight.value = height;
125-
originalImageWidth.value = width;
122+
// We need to have image sizes in shared values to properly calculate position/size/animation
123+
ImageSize.getSize(imageUri).then(({width, height, rotation: orginalRotation}) => {
124+
// On Android devices ImageSize library returns also rotation parameter.
125+
if (orginalRotation === 90 || orginalRotation === 270) {
126+
originalImageHeight.value = width;
127+
originalImageWidth.value = height;
128+
} else {
129+
originalImageHeight.value = height;
130+
originalImageWidth.value = width;
131+
}
132+
126133
setIsImageInitialized(true);
127134

128135
// Because the reanimated library has some internal optimizations,

0 commit comments

Comments
 (0)