Benchmark error: UnsupportedError { format: Exact(Jpeg), kind: Color(Rgba8) }
Hi!
I observed an error during the library benchmarking.
Expected
The benchmark completes successfully with the documented command.
Actual behaviour
The benchmark fails with the following error:
taskset -c 0 cargo +nightly bench --features=benchmarks
<lines are omitted for clarity>
...
encode-jpeg/zero-Rgb8-file/256
time: [1.2626 ms 1.2630 ms 1.2635 ms]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
Benchmarking encode-jpeg/zero-Rgba8-rawvec/64: Warming up for 3.0000 sthread 'main' panicked at benches/encode.rs:132:41:
called `Result::unwrap()` on an `Err` value: Unsupported(UnsupportedError { format: Exact(Jpeg), kind: Color(Rgba8) })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: bench failed, to rerun pass `--bench encode`
Reproduction steps
- Run
cargo +nightly bench --features=benchmarks - Wait until the
encode-jpeg/zero-Rgba8-rawvec/64the benchmark will start - Get the error
Environment info:
- OS: Fedora 39
- Kernel: 6.8.7
- Rustc version: 1.80.0-nightly
imageversion:mainbranch,5013041c830c2f5aa189cccc7f8902ce22e283c7commit
The JPEG format cannot store an alpha channel. See #2211
Looks like the benchmark needs to be updated to strip the alpha channel or skip those images
I am also getting this error when upgrading from 0.24.6 to 0.25.2 on the same image file.
PR welcome!
fn main() {
let img = image::open("in.jpg").unwrap();
println!("Loaded");
let buffer = image::imageops::resize(&img, 500, 500, image::imageops::FilterType::Lanczos3);
buffer.save("out.jpg").unwrap(); // <- crashes in .save()
}
So this code works with 0.24.6, but crashes with 0.25.2. Not sure if it happens for every image, but I tried a handful and it crashes everytime.
That's annoying but expected. Calling resize on a DynamicImage produces an RgbaImage due to a quirk of how the GenericImageView trait works. Trying to save an RGBA image as JPEG fails because the JPEG file format cannot store an alpha channel
+1, any update?
Status is the same as it was five days ago:
PR welcome!