[Image-SIG] Patch: Better compression of png-images

Flynn Marquardt pil at flynnux.de
Wed Jul 22 11:34:48 CEST 2009


Hi,

the achieved compression rates of png images created by python-imaging
are really bad, programs like optipng or pncrush can compress these
images much better, often only to 30-50% of the size generated by pil.

Looking into the code I found these lines in libImaging/ZipEncode.c:

                // err = deflate(&context->z_stream, Z_NO_FLUSH);

                /* FIXME: temporary workaround for problem with recent
                   versions of zlib -- 990709/fl */

                err = deflate(&context->z_stream, Z_SYNC_FLUSH);

Reverting this to:
                
		err = deflate(&context->z_stream, Z_NO_FLUSH);

                /* FIXME: temporary workaround for problem with recent
                   versions of zlib -- 990709/fl */

                // err = deflate(&context->z_stream, Z_SYNC_FLUSH);

improves the compression (close) to the desired optimum. I think the
mentioned bug in zlib is fixed, it is ten years ago.

For me it works fine, can somebody who understands more of this topic,
confirm this?

Flynn




More information about the Image-SIG mailing list