Map errors to ErrNo::Io
@@ -32,14 +32,14 @@ fn process_image() -> Result<(), wasi_types::ErrNo> {
// `open` returns a `DynamicImage` on success.
// By default, jpeg-decode reads JPEG images in parallel threads (cf. rayon), which aren't
// supported in WASM. The workaround is to read PNG images instead
- let mut img = image::open("/test.png").map_err(|_| ErrNo::Proto)?;
+ let mut img = image::open("/test.png").map_err(|_| ErrNo::Io)?;
// Transform the image
let subimg = imageops::crop(&mut img, 0, 0, 100, 100);
println!("new dimensions: {:?}", subimg.dimensions());
// Write the contents of this image to the Writer in PNG format.
- subimg.to_image().save_with_format("/output", ImageFormat::Png).unwrap();
+ subimg.to_image().save_with_format("/output", ImageFormat::Png).map_err(|_| ErrNo::Io)?;
Ok(())
}
