@@ -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