https://kotlinlang.org logo
#korge
Title
# korge
b

benkuly

05/04/2022, 5:21 AM
Hi 🙂 I get
UnsupportedOperationException: No suitable image format : MAGIC:ノPNG(89504e47) (ノPNG)
when running this code in nodeJs. It works on JVM and js/browser:
Copy code
suspend fun createThumbnail(file: ByteArray, maxWidth: Int, maxHeight: Int): Thumbnail {
    val image = file.asMemoryVfsFile().readNativeImage() <-- I think the exception throws here.
    val resizedImage = image.resizedUpTo(maxWidth, maxHeight)
    return Thumbnail(resizedImage.encode(PNG), ContentType.Image.PNG, resizedImage.width, resizedImage.height)
}
Any idea? Maybe I'm using the API wrong.
5 Views