Write of .png image and readback is not identical

⚓ Rust    📅 2026-02-18    👤 surdeus    👁️ 6      

surdeus

Using the "image" crate, I've read a .png file, written it to a new .png file, and read it back. The image content matches.
(I checked by differencing the images with Gimp.)
The metadata, as displayed by metadataview.com, is the same, except for the checksum. The file header bytes match. The file lengths differ slightly, which is puzzling.

This is weird but OK. I just need a hash of the image for de-duplication purposes. The hash function of the image crate gives different hashes for these files. Is there some function that gives me a hash of just the image bytes? Yes, I could write one, but it would probably be slow.

(Tried to upload the images here, but this forum system converts them to JPEG, which would just confuse the issue. They're map tiles for a virtual world. They can change, but seldom do, so a mapping system needs to detect changes.)

6 posts - 4 participants

Read full topic

🏷️ Rust_feed