Merge pull request #2886 from Aga-C/fix-image-resizing
Fixed exception on image resizing (#2883)
This commit is contained in:
commit
d45c371217
|
@ -87,7 +87,7 @@ class ResizeMultipleImagesDialog(
|
||||||
val lastModified = File(path).lastModified()
|
val lastModified = File(path).lastModified()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resizeImage(path, size) {
|
resizeImage(path, path, size) {
|
||||||
if (it) {
|
if (it) {
|
||||||
pathsToRescan.add(path)
|
pathsToRescan.add(path)
|
||||||
pathLastModifiedMap[path] = lastModified
|
pathLastModifiedMap[path] = lastModified
|
||||||
|
|
|
@ -799,7 +799,7 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un
|
||||||
val file = File(newPath)
|
val file = File(newPath)
|
||||||
val pathLastModifiedMap = mapOf(file.absolutePath to file.lastModified())
|
val pathLastModifiedMap = mapOf(file.absolutePath to file.lastModified())
|
||||||
try {
|
try {
|
||||||
resizeImage(newPath, newSize) { success ->
|
resizeImage(path, newPath, newSize) { success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
toast(R.string.file_saved)
|
toast(R.string.file_saved)
|
||||||
|
|
||||||
|
@ -822,17 +822,17 @@ fun BaseSimpleActivity.launchResizeImageDialog(path: String, callback: (() -> Un
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BaseSimpleActivity.resizeImage(path: String, size: Point, callback: (success: Boolean) -> Unit) {
|
fun BaseSimpleActivity.resizeImage(oldPath: String, newPath: String, size: Point, callback: (success: Boolean) -> Unit) {
|
||||||
var oldExif: ExifInterface? = null
|
var oldExif: ExifInterface? = null
|
||||||
if (isNougatPlus()) {
|
if (isNougatPlus()) {
|
||||||
val inputStream = contentResolver.openInputStream(Uri.fromFile(File(path)))
|
val inputStream = contentResolver.openInputStream(Uri.fromFile(File(oldPath)))
|
||||||
oldExif = ExifInterface(inputStream!!)
|
oldExif = ExifInterface(inputStream!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
val newBitmap = Glide.with(applicationContext).asBitmap().load(path).submit(size.x, size.y).get()
|
val newBitmap = Glide.with(applicationContext).asBitmap().load(oldPath).submit(size.x, size.y).get()
|
||||||
|
|
||||||
val newFile = File(path)
|
val newFile = File(newPath)
|
||||||
val newFileDirItem = FileDirItem(path, path.getFilenameFromPath())
|
val newFileDirItem = FileDirItem(newPath, newPath.getFilenameFromPath())
|
||||||
getFileOutputStream(newFileDirItem, true) { out ->
|
getFileOutputStream(newFileDirItem, true) { out ->
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
out.use {
|
out.use {
|
||||||
|
|
Loading…
Reference in New Issue