Fuse Community

PNG support on ImageTools.getImageFromBase64(base64)

It seems that getImageFromBase64(base64) has lack of support on different type of image format, I could see that it always save the image with JPEG extension. This is not a problem in desktop , it seems that preview platform would ignore the file extension and just check the image signature. In my case, the PNG image with transparency pixel still rendered correctly even though the file extension says .jpg , but this is not the case for Android (fuse-preview app), it is treated as the extension says, the alpha is ignored hence the transparency is failed.

Curiously, its neighbour method getImageFromBuffer(imageData) have capability to write correctly based on the image signature (at least in Android), but unfortunately this method is not available on Desktop . So, my current workaround is on desktop environment, I stay with base64 format, but on mobile (iOS and Android) I will convert the base64 data to buffer through Base64 Tools , and call the buffer version instead. And then I realize, why cannot we merge these to function?

For getImageFromBuffer(imageData) on Desktop, instead of not supporting it , you can just convert the buffer into base64 and then call the getImageFromBase64(base64)

And for getImageFromBase64(base64) on mobile, instead of using mechanism that cannot recognize the actual image type, you can just convert the base64 string into buffer and call getImageFromBuffer(imageData)

But perhaps you have a certain purpose or reason why this two method behaves differently, but still support for popular image format is needed in any case. Thanks

It seems that this is a discrepancy that has historically creeped in. It also seems that ImageTools will not be getting much attention in near future. Perhaps a better alternative will eventually make its debut, but there are no details or ETA on if and when.