From 82d93f56d4c4661d0ecacf20fc319adeb5835f4d Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 21 Oct 2017 23:19:05 +0200 Subject: [PATCH] attach exif data to images whenever possible --- app/build.gradle | 2 +- .../com/simplemobiletools/camera/PhotoProcessor.kt | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 595dffe9..51ec5ada 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -37,7 +37,7 @@ android { } dependencies { - compile 'com.simplemobiletools:commons:2.30.7' + compile 'com.simplemobiletools:commons:2.30.9' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt b/app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt index c50cef5f..40d171fd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt @@ -35,6 +35,13 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId } val data = params[0] + val tempFile = File.createTempFile("simple_temp_exif", "") + val tempFOS = FileOutputStream(tempFile) + tempFOS.use { + tempFOS.write(data) + } + val tempExif = ExifInterface(tempFile.absolutePath) + val photoFile = File(path) if (activity.needsStupidWritePermissions(path)) { if (activity.config.treeUri.isEmpty()) { @@ -87,7 +94,9 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId if (path.startsWith(activity.internalStoragePath)) { exifOrientation = getExifOrientation(totalRotation) } + tempExif.copyTo(fileExif) fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation) + fileExif.saveAttributes() return photoFile.absolutePath } catch (e: Exception) {