-
Notifications
You must be signed in to change notification settings - Fork 41
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 .gif #138
Comments
This image is missing a Trailer block to end its data stream. The netbpm tools agree with this:
Frames before this are handled fine but eagerly decoding the complete file will surface the error. Is there any other error strategy that we could do here instead to recover? |
Im having the same problem. Now gif won't decode anything, it fails with wget "https://ipfs.io/ipfs/bafybeihqwohkbcwf2egmwd4lnriaa63xc3eqfbyb4i4qftjikyp5wtwlqi/5220.gif" -O claydino.gif
giftopnm claydino.gif > /dev/null With gif lib (code available here ) [2022-11-29T16:34:13Z INFO imgopt::utils] Opening file:: storage/base/ipfs/bafybeihqwohkbcwf2egmwd4lnriaa63xc3eqfbyb4i4qftjikyp5wtwlqi/5220.gif
[2022-11-29T16:34:13Z INFO imgopt::utils] reading image from file: took 638 µs
[2022-11-29T16:34:13Z WARN imgopt::img] starting read_info
[2022-11-29T16:34:13Z ERROR imgopt::img] unexpected EOF Is there something we can do to handle the 'unexpected EOF' error? |
nvm, its working again, my fault, sorry. I think(?) this was causing the error. let mut file = fs::File::open(input_path)?;
// I was moving the data into a vec before using read_info
let mut data = Vec::new();
file.read_to_end(&mut data)?;
//// Moving the above after using read_info solved the issue
let mut reader = {
let mut options = gif::DecodeOptions::new();
options.set_color_output(gif::ColorOutput::Indexed);
options.allow_unknown_blocks(true);
options.read_info(&file).unwrap()
};
/* moved here
let mut data = Vec::new();
file.read_to_end(&mut data)?;
*/ |
Yeah, read_to_end leaves the file descriptor pointing at the end of the file. If the decoder later tries to read even a single byte it'll get back an error that there's no more data to read |
I call read_info() first. Is there a way to tolerate GIF files without a trailer block the way a browser will? |
In 0.11.4, I can't get this to decode: I get DecodingFormatError { underlying: "unexpected EOF" }
It works in Chrome/Win/Brave.
https://user-images.githubusercontent.com/657201/139770827-18e25c4e-eb0a-4058-ba48-ddc3849090ee.gif
The text was updated successfully, but these errors were encountered: