Skip to content

Commit 3cac304

Browse files
committed
set the photo exif a bit later after saving
1 parent 84d4c1f commit 3cac304

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
6666
}
6767

6868
val totalRotation = (imageRot + deviceRot + previewRot) % 360
69-
val fileExif = ExifInterface(path)
70-
var exifOrientation = ExifInterface.ORIENTATION_NORMAL.toString()
71-
if (path.startsWith(activity.internalStoragePath)) {
72-
exifOrientation = getExifOrientation(totalRotation)
73-
} else {
69+
if (!path.startsWith(activity.internalStoragePath)) {
7470
image = rotate(image, totalRotation)
7571
}
7672

@@ -84,11 +80,13 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
8480
image = Bitmap.createBitmap(image, 0, 0, image.width, image.height, matrix, false)
8581
}
8682

87-
if (image != null) {
88-
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
89-
fos?.close()
90-
}
83+
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
9184

85+
val fileExif = ExifInterface(path)
86+
var exifOrientation = ExifInterface.ORIENTATION_NORMAL.toString()
87+
if (path.startsWith(activity.internalStoragePath)) {
88+
exifOrientation = getExifOrientation(totalRotation)
89+
}
9290
fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation)
9391
fileExif.saveAttributes()
9492
return photoFile.absolutePath

0 commit comments

Comments
 (0)