[pngcsum] Chunk CheckSum Correction



[download pngcsum]

CheckSum Correction with PNGCSum

Each chunk in a PNG image is verified for corrupted data using a CRC32 checksum, where CRC stands for Cyclic Redundancy Checksum. Check out the PNG Specification at W3C for more details on how the checksum is constructed.

The four parts of a chunk are:

  • a four byte length field,
  • the chunk name, also four bytes,
  • followed by the data and
  • at the end a four byte field with the checksum.
The checksum is created from the chunk name field and the data, therefore not including the length field.

When you modify a PNG image by hand, like what I did to create PngSuite, the data changes and the checksum isn't valid anymore. For that purpose I created this little tool, called pngcsum, that takes such a modified PNG, recalculates the checksums and writes it out to a now valid PNG file. The tool assumes that while the data in a chunk can be changed or currupted, the length field of the chunk is still correct.

The tar-ball contains the C source code and a Linux binary, which was compiled on Cent-OS 4.


[back to PNG] [Download page] [png] [PngSuite]


  Willem van Schaik, Calgary, April 2011     http://www.schaik.com/wwwillem.html