image icon indicating copy to clipboard operation
image copied to clipboard

Reduce preallocated buffer of PNG decoder

Open gyk opened this issue 3 years ago • 0 comments

I would like to be able to probe the metadata of a bunch of images quickly, similar to what imagesize does but with the potential to extract more info like color type. image::io::Reader works well for most formats, however, it reads more data than expected for PNG and TIFF.

The reason is the PNG decoder uses a BufReader with 32KB buffer size, which is not optimal for this use case. It should be able to detect the metadata by only looking at the first few bytes (although the actual read length is as long as the first sector).

Could we make the buffer size of PNG decoder configurable?

Related to #1007.

gyk avatar Jan 28 '22 13:01 gyk