From 4bc1bcd32290eb2a5f66435d3698634b5b51f202 Mon Sep 17 00:00:00 2001 From: Yaron Budowski Date: Mon, 16 Sep 2024 13:07:29 +0200 Subject: [PATCH] #1358 - crash fix --- .../java/org/inaturalist/android/ImageUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java b/iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java index 8e66ab91..be49b5f4 100644 --- a/iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java +++ b/iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java @@ -379,8 +379,11 @@ public static String resizeImage(Context context, String path, Uri photoUri, int Logger.tag(TAG).error(exc); return null; } - } else { + } else if (path != null) { is = new FileInputStream(new File(path)); + } else { + Logger.tag(TAG).error("Both path and URI are null"); + return null; } // Just read the input image dimensions @@ -393,8 +396,12 @@ public static String resizeImage(Context context, String path, Uri photoUri, int // BitmapFactory.decodeStream moves the reading cursor is.close(); - androidx.exifinterface.media.ExifInterface exif = new androidx.exifinterface.media.ExifInterface(path); - int rotationDegrees = exif.getRotationDegrees(); + int rotationDegrees = 0; + + if (path != null) { + androidx.exifinterface.media.ExifInterface exif = new androidx.exifinterface.media.ExifInterface(path); + rotationDegrees = exif.getRotationDegrees(); + } if (photoUri != null) { is = context.getContentResolver().openInputStream(photoUri);