PNG Chunks
-
I'm writing a chunks collection program in png, please tell me how chunk idata is built? And if the chunk compression is used, what is the Python3 module available for compression?
-
You can look at the source of the library. https://github.com/jcrocholl/pypng/blob/master/lib/png.py where the reading/recording at PNG on a pure python has been completed. There's a universal method.
Reader.read_chank()
which reads the chunk and returns its type and data and methodReader.read()
where all the sausage algorithms and the paintings implemented.The key moment of data dispensation is here:
scanlines = array('B', zlib.decompress(''.join(compressed))) if interlaced: pixels = self.deinterlace(scanlines) else: pixels = self.read_flat(scanlines)
(in variables)
compressed
raw data from all chancsIDAT
)It is not difficult to figure out from the example that the data-packing module is called zlib.