Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark error: UnsupportedError { format: Exact(Jpeg), kind: Color(Rgba8) } #2227

Open
zamazan4ik opened this issue May 4, 2024 · 7 comments

Comments

@zamazan4ik
Copy link

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

  1. Run cargo +nightly bench --features=benchmarks
  2. Wait until the encode-jpeg/zero-Rgba8-rawvec/64 the benchmark will start
  3. Get the error

Environment info:

  • OS: Fedora 39
  • Kernel: 6.8.7
  • Rustc version: 1.80.0-nightly
  • image version: main branch, 5013041c830c2f5aa189cccc7f8902ce22e283c7 commit
@fintelia
Copy link
Contributor

fintelia commented May 4, 2024

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

@marvin-j97
Copy link
Contributor

marvin-j97 commented Oct 6, 2024

I am also getting this error when upgrading from 0.24.6 to 0.25.2 on the same image file.

@fintelia
Copy link
Contributor

fintelia commented Oct 6, 2024

PR welcome!

@marvin-j97
Copy link
Contributor

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.

@fintelia
Copy link
Contributor

fintelia commented Oct 6, 2024

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

@thep0y
Copy link

thep0y commented Oct 11, 2024

+1, any update?

@fintelia
Copy link
Contributor

Status is the same as it was five days ago:

PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants