png-image: Library to view and modify PNG chunks.
will allow programmers to dissect
a PNG image to view its contents separated by its chunks. This module
provides all of the below procedures, even if they’re in separate
Checks if the given path or byte string is a valid PNG image.
Given a valid PNG image, returns an immutable hash
where each key is
the name of a chunk (which is itself a hash). If a chunk may appear multiple
times according to the PNG spec, then the chunk information is wrapped inside
a list of hashes. In txt chunks, if the text has been deflated, it will be
inflated in this step.
The chunk hashes have the keys '(type data length crc32).
Given a hash, returns a valid PNG image as a byte string. If converted from
one form to the other, the resulting byte string may not be identical to the
original bytes due to the ordering of the chunks, but all the chunks should
be inside the final result. If the hash has iTXt chunks, the text data will
be deflated if it exceeds 1024 bytes.
About text chunks:
* tEXt data hashes have the keys '(keyword text).
* zTXt data hashes have the keys '(keyword compression-method text).
* iTXt data hashes have the keys '(keyword compression-flag compression-method language-tag translated-keyword text).
* The only valid compression-method value is #"\0".
Take an incomplete chunk that contains only the data and create a hash.
In iTXt, if the data is longer than 1024 bytes, it will NOT be deflated here.
Take an incomplete chunk hash and return incomplete data.
Create a complete chunk with the keyword. In iTXt, if str exceeds
1024 bytes, it will be deflated. In zTXt, str will always be
Create a complete hash from the complete chunk bytes. In iTXt, if
the text from chunk is deflated, it will be inflated in this step.
In zTXt, the text will always be deflated.
Calculates the CRC32 of the byte string and returns a decimal integer.
Calculates the ADLER32 of the byte string and returns a decimal integer.