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


_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to