Skip to content

Commit 2e542df

Browse files
dcalhounclaude
andcommitted
fix: read EXIF orientation directly for plain file paths
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) <noreply@anthropic.com>
1 parent ccee838 commit 2e542df

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ public static int getImageOrientation(Context ctx, String filePath) {
9090
filePath = filePath.replace("file://", "");
9191

9292
if (!filePath.contains("content://")) {
93+
// A plain filesystem path pointing at an existing file (e.g. an app cache file) is not
94+
// resolvable through the MediaStore content provider — prefixing it with
95+
// "content://media" would produce a bogus Uri whose query always fails (throwing on
96+
// some devices). EXIF is the only orientation source such a file has, so read it
97+
// directly.
98+
if (new File(filePath).exists()) {
99+
return getExifOrientation(filePath);
100+
}
93101
curStream = Uri.parse("content://media" + filePath);
94102
} else {
95103
curStream = Uri.parse(filePath);

0 commit comments

Comments
 (0)