def mpng_reflate_cli(args): input_png = args.input output_png = args.output or input_png.replace('.png', '_reflated.png') level = args.recompress_level or 6 extract_only = args.extract_only replace_data = args.replace
Standard compression tools like 7-Zip or WinRAR often struggle with already-compressed files like PNGs. By using -mpng+reflate , you are essentially "unwrapping" the PNG's internal compression so that a more powerful compressor (like or LZMA ) can achieve a much higher ratio.
It will:
According to discussions on the Encode.su forum , combining these methods allows the -reflate codec to work on top of the reconstructed stream for maximum efficiency. How to Use It
PNG images often use the DEFLATE algorithm for compression, which is a combination of LZ77 and Huffman coding. DEFLATE is a widely used compression algorithm in various formats, including PNG, ZIP, and gzip.
def read_chunk(f): """Read PNG chunk: length, type, data, crc""" len_data = struct.unpack('>I', f.read(4))[0] chunk_type = f.read(4) data = f.read(len_data) crc = struct.unpack('>I', f.read(4))[0] return chunk_type, data, crc