Fixing crash when image is an SVG and tries to compress.

This commit is contained in:
Vitor Pamplona
2023-12-05 21:45:56 -05:00
parent f458f00edc
commit 6662966ab3
@@ -69,11 +69,16 @@ class MediaCompressor {
} }
} }
) )
} else if (contentType?.startsWith("image", true) == true && !contentType.contains("gif")) { } else if (contentType?.startsWith("image", true) == true && !contentType.contains("gif") && !contentType.contains("svg")) {
val compressedImageFile = Compressor.compress(applicationContext, from(uri, contentType, applicationContext)) { try {
default(width = 640, format = Bitmap.CompressFormat.JPEG) val compressedImageFile = Compressor.compress(applicationContext, from(uri, contentType, applicationContext)) {
default(width = 640, format = Bitmap.CompressFormat.JPEG)
}
onReady(compressedImageFile.toUri(), contentType, compressedImageFile.length())
} catch (e: Exception) {
e.printStackTrace()
onReady(uri, contentType, null)
} }
onReady(compressedImageFile.toUri(), contentType, compressedImageFile.length())
} else { } else {
onReady(uri, contentType, null) onReady(uri, contentType, null)
} }