keep exif data at editing images from Android 7+

This commit is contained in:
tibbi 2018-12-17 20:00:44 +01:00
parent ee9749ba3b
commit 5b22d06ff9
1 changed files with 16 additions and 0 deletions

View File

@ -1,12 +1,15 @@
package com.simplemobiletools.gallery.pro.activities
import android.annotation.TargetApi
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Bitmap.CompressFormat
import android.graphics.Color
import android.graphics.Point
import android.media.ExifInterface
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.MediaStore
import android.view.Menu
@ -24,6 +27,7 @@ import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.OTG_PATH
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
import com.simplemobiletools.commons.helpers.isNougatPlus
import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.pro.R
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
@ -576,6 +580,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
}
}
@TargetApi(Build.VERSION_CODES.N)
private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) {
if (showSavingToast) {
toast(R.string.saving)
@ -587,6 +592,17 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} else {
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
}
try {
if (isNougatPlus()) {
val inputStream = contentResolver.openInputStream(uri)
val oldExif = ExifInterface(inputStream)
val newExif = ExifInterface(file.absolutePath)
oldExif.copyTo(newExif, false)
}
} catch (e: Exception) {
}
setResult(Activity.RESULT_OK, intent)
scanFinalPath(file.absolutePath)
out.close()