mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
improve exif orientation detecting from content uri images
This commit is contained in:
parent
7e234d731a
commit
81abbe82ad
1 changed files with 10 additions and 2 deletions
|
@ -530,8 +530,16 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
try {
|
||||
val path = mMedium.path
|
||||
val exif = android.media.ExifInterface(path)
|
||||
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
||||
orient = if (path.startsWith("content:/")) {
|
||||
val inputStream = context!!.contentResolver.openInputStream(Uri.parse(path))
|
||||
val exif = ExifInterface()
|
||||
exif.readExif(inputStream, ExifInterface.Options.OPTION_ALL)
|
||||
val tag = exif.getTag(ExifInterface.TAG_ORIENTATION)
|
||||
tag?.getValueAsInt(defaultOrientation) ?: defaultOrientation
|
||||
} else {
|
||||
val exif = android.media.ExifInterface(path)
|
||||
exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
||||
}
|
||||
|
||||
if (orient == defaultOrientation || context!!.isPathOnOTG(mMedium.path)) {
|
||||
val uri = if (path.startsWith("content:/")) Uri.parse(path) else Uri.fromFile(File(path))
|
||||
|
|
Loading…
Reference in a new issue