You could try adapting https://github.com/google/wuffs/tree/main/script/bench-rust-...
> https://github.com/bschwind/png-decoder
Note that statements like:
let bytes_per_scanline = ((header.width * header.bit_depth as u32 * header.color_type.sample_multiplier()) + 7) / 8;
can silently overflow a u32 if width is 0x800_0000, bit_depth is 8 and sample_multiplier is 4. Part of the point of Wuffs is to catch things like that (at compile time).