Image crate, asmjs target

should a crate like 'image' (i'm after jpg decoding etc) work in the asmjs-unknown-emscripten target, .. how would you set this up in cargo

I can of course defer the work of image decoding to the browser (? .. have a js function to grab the image and just call that ) , but it would be nice to know how to get all this working on the rust side ;

I've compiled image for asmjs emscripten. Didn't take any special configuration beyond what getting other asmjs emscripten stuff working. (Though it was only able to decode png files; jpegs caused a crash.)

1 Like

Ok, thanks for confirmation that (some of) it should work.

(I did get the 'use the-browser' approach working so I have the use of images now, but I still want this..)

I note the crate brings in a load of dependancies including Rayon, is it trying to do some fancy parallel threading (not supported in the browser) .. in c++land I was using some simple single source jpeg decoder sometimes, is there something like that lying around in Rust

Someone told me that the multi threading was the problem with the jpeg decoding. In the image crate Cargo.toml, there's an optional scoped threadpool. I tried disabling it but no luck avoiding the crash. As far as I know the image crate is the only rust jpeg decoder, though I'm sure there are bindings to c libraries out there.