From 2e542df55715dff22c21def058bea551ee9569d0 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 23 Jul 2026 11:16:12 -0400 Subject: [PATCH] fix: read EXIF orientation directly for plain file paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getImageOrientation prefixed non-content paths with "content://media" and queried the MediaStore content provider first, falling back to EXIF when that failed. For a plain filesystem path pointing at an existing file (e.g. an app cache file), that constructed Uri is never resolvable and the query always fails — on some devices by throwing IllegalArgumentException ("Volume data not found"), which was logged as an error with a stack trace on every call. Such files carry their orientation only in EXIF, so read it directly and skip the doomed provider query. MediaStore-style paths (which do not exist on the filesystem) keep the previous behavior. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../main/java/org/wordpress/android/util/ImageUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java index fed838316..1fc97d37e 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java @@ -90,6 +90,14 @@ public static int getImageOrientation(Context ctx, String filePath) { filePath = filePath.replace("file://", ""); if (!filePath.contains("content://")) { + // A plain filesystem path pointing at an existing file (e.g. an app cache file) is not + // resolvable through the MediaStore content provider — prefixing it with + // "content://media" would produce a bogus Uri whose query always fails (throwing on + // some devices). EXIF is the only orientation source such a file has, so read it + // directly. + if (new File(filePath).exists()) { + return getExifOrientation(filePath); + } curStream = Uri.parse("content://media" + filePath); } else { curStream = Uri.parse(filePath);