Skip to content

Commit

Permalink
#1358 - crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
budowski committed Sep 16, 2024
1 parent 5c9287c commit 4bc1bcd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions iNaturalist/src/main/java/org/inaturalist/android/ImageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit 4bc1bcd

Please sign in to comment.