You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I basically copied all the bytes of a png into another file (.pnle which is just smth i made up for a temp file). So technically up until the first IDAT chunk, all the metadata before should 100% be right.
I open the .pnle using png::Decoder to get a decoder object, then i call decoder.read_info(), which according to the spec and the src code, should read until the first IDAT. However, i truncate my .pnle a little bit towards the end, but all the metadata before the first IDAT is untouched. When the read_info func is called, it errors out giving me a MissingImageData inner error. Only, when i have the full entire png in the pnle does the read_info func complete.
In the Decoder src, read_info() calls read_until_image_data() and everytime it crashes saying that it's reached Decoded::ImageEnd already, which is only returned in stream.rs if it's found IEND.
The text was updated successfully, but these errors were encountered:
Are you sure you didn't entirely remove the IDAT chunks? The decoder can't know it has reached the image data until it sees a chunk with type=IDAT. If it hits the end of the input first it'll return a MissingImageData error.
@fintelia Im doing this (basically the example usage for this crate):
let encoder = png::Encoder::with_info(w, img_info)?;
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(data);
But im not fully writing down all the data. If i do &data[..data.len()-1], it doesn't seem to work but there should at least be a single IDAT? Or am i misunderstanding an IDAT or something?
I was just looking for a function that could parse all the ihdr chunks and pallete, everything not including the data.
I'd have to look into the implementation of write_image_data to be sure, but I think the writer might wait to write an IDAT until it has enough data buffered and/or a full frame worth of data has been written.
I basically copied all the bytes of a png into another file (.pnle which is just smth i made up for a temp file). So technically up until the first IDAT chunk, all the metadata before should 100% be right.
I open the .pnle using
png::Decoder
to get a decoder object, then i calldecoder.read_info()
, which according to the spec and the src code, should read until the first IDAT. However, i truncate my .pnle a little bit towards the end, but all the metadata before the first IDAT is untouched. When theread_info
func is called, it errors out giving me aMissingImageData
inner error. Only, when i have the full entire png in the pnle does the read_info func complete.In the Decoder src,
read_info()
callsread_until_image_data()
and everytime it crashes saying that it's reached Decoded::ImageEnd already, which is only returned instream.rs
if it's found IEND.The text was updated successfully, but these errors were encountered: