my fork of the bluesky client

Fix camera orientation on Android (#6729)

authored by danabra.mov and committed by GitHub 61e97d69 9d3bdbb2

+39
patches/react-native-image-crop-picker+0.41.2.patch
··· 1 + diff --git a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java 2 + index 5de0845..fa477e7 100644 3 + --- a/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java 4 + +++ b/node_modules/react-native-image-crop-picker/android/src/main/java/com/reactnative/ivpusic/imagepicker/PickerModule.java 5 + @@ -21,6 +21,7 @@ import android.webkit.MimeTypeMap; 6 + 7 + import androidx.core.app.ActivityCompat; 8 + import androidx.core.content.FileProvider; 9 + +import androidx.exifinterface.media.ExifInterface; 10 + 11 + import com.facebook.react.bridge.ActivityEventListener; 12 + import com.facebook.react.bridge.Callback; 13 + @@ -678,6 +679,15 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi 14 + throw new Exception("Cannot select remote files"); 15 + } 16 + BitmapFactory.Options original = validateImage(path); 17 + + ExifInterface originalExif = new ExifInterface(path); 18 + + int orientation = originalExif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); 19 + + boolean invertDimensions = ( 20 + + orientation == ExifInterface.ORIENTATION_ROTATE_90 || 21 + + orientation == ExifInterface.ORIENTATION_ROTATE_270 || 22 + + orientation == ExifInterface.ORIENTATION_TRANSPOSE || 23 + + orientation == ExifInterface.ORIENTATION_TRANSVERSE 24 + + ); 25 + + 26 + 27 + // if compression options are provided image will be compressed. If none options is provided, 28 + // then original image will be returned 29 + @@ -687,8 +697,8 @@ class PickerModule extends ReactContextBaseJavaModule implements ActivityEventLi 30 + long modificationDate = new File(path).lastModified(); 31 + 32 + image.putString("path", "file://" + compressedImagePath); 33 + - image.putInt("width", options.outWidth); 34 + - image.putInt("height", options.outHeight); 35 + + image.putInt("width", invertDimensions ? options.outHeight : options.outWidth); 36 + + image.putInt("height", invertDimensions ? options.outWidth : options.outHeight); 37 + image.putString("mime", options.outMimeType); 38 + image.putInt("size", (int) new File(compressedImagePath).length()); 39 + image.putString("modificationDate", String.valueOf(modificationDate));