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

Fails to decode jpeg headers for image with width or height > 16384 px #2170

Closed
GtenIOS opened this issue Mar 18, 2024 · 0 comments · Fixed by #2175
Closed

Fails to decode jpeg headers for image with width or height > 16384 px #2170

GtenIOS opened this issue Mar 18, 2024 · 0 comments · Fixed by #2175

Comments

@GtenIOS
Copy link

GtenIOS commented Mar 18, 2024

This happens in the latest public release of this crate on this date, i.e. 0.25

Expected

Should be able to decode the image incase the Limit is turned off (using reader.no_limits()) or set to > 16384 (custom Limit with max_image_width and max_image_height set to the desired amount, 26560 in my case)

Actual behaviour

Fails with error message from zune_jpeg crate:
Error: Decoding(DecodingError { format: Exact(Jpeg), underlying: Some("Image width 26560 greater than width limit 16384. If use `set_limits` if you want to support huge images") })

Reproduction steps

Provide source code, a repository link, or steps

use std::io::BufReader;
use std::fs::File;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut reader = image::io::Reader::new(BufReader::new(File::open("./canvas.jpg")?));  // image with res 26560x26560
    // let mut limits = image::io::Limits::default();
    // limits.max_image_width = Some(30000);
    // limits.max_image_height = Some(30000);
    // reader.limits(limits);
    reader.no_limits();
    reader = reader.with_guessed_format()?;
    let _img = reader.decode()?;
    Ok(())
}

Generated canvas.jpg for testing using Imagemagick with command below:
convert -size 26560x26560 xc:white canvas.jpg

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

Successfully merging a pull request may close this issue.

1 participant