Fix "Unsupported image format" error
This commit is contained in:
@@ -88,12 +88,12 @@ class PageLoader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun convertInPlace(file: File) {
|
suspend fun convertInPlace(file: File) {
|
||||||
convertLock.withLock(file) {
|
convertLock.withLock(Lock) {
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
val image = BitmapFactory.decodeFile(file.absolutePath)
|
val image = BitmapFactory.decodeFile(file.absolutePath)
|
||||||
try {
|
try {
|
||||||
file.outputStream().use { out ->
|
file.outputStream().use { out ->
|
||||||
image.compress(Bitmap.CompressFormat.WEBP, 100, out)
|
image.compress(Bitmap.CompressFormat.PNG, 100, out)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
image.recycle()
|
image.recycle()
|
||||||
@@ -101,4 +101,6 @@ class PageLoader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object Lock
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user