niutech / jxl.js

JPEG XL decoder in JavaScript using WebAssembly (WASM)
https://niutech.github.io/jxl.js/
Apache License 2.0
326 stars 17 forks source link

Support for embedded image decoding #9

Open WhoseTheNerd opened 1 year ago

WhoseTheNerd commented 1 year ago

Decoding support for base64 embedded jpeg xl images would be nice. Any plans for that?

WhoseTheNerd commented 1 year ago

I managed to do this by adding el.src.startsWith("data:image/jpegxl;base64,") to the MutationObserver if list and all jxlSrc used in caching context gets encodeURIComponent(jxlSrc)

Resulting jxl.js looks like this

niutech commented 1 year ago

Thanks, but what's the real world use case for this?

WhoseTheNerd commented 1 year ago

It allows me not to deal with image files, since they are all embedded into single file, i.e. all images, js, css and etc. You can think of it as something similar to SingleFile.

niutech commented 1 year ago

The MIME type image/jpegxl is still not standardized by IANA. There is a feature request for another MIME type image/jxl, so we cannot reliably use this one or another to detect JPEG XL images. It' the best to wait until it gets standardized.

redthing1 commented 1 year ago

How to do this with blob image data?

niutech commented 1 year ago

@redthing1 See https://github.com/niutech/jxl.js/issues/9#issuecomment-1374445726

QINGCHARLES commented 1 year ago

The MIME type image/jpegxl is still not standardized by IANA. There is a feature request for another MIME type image/jxl, so we cannot reliably use this one or another to detect JPEG XL images. It' the best to wait until it gets standardized.

It would be fine to check for either MIME type as there are no conflicts with other types.