[Image-SIG] Use of Z_SYNC_FLUSH in libImaging/ZipEncode.c

David Bolen db3l at fitlinxx.com
Thu Sep 1 01:40:31 CEST 2005


While looking into why round-tripping a small PNG image through PIL expanded
the file size noticeable (several hundred % for very small images), I
isolated it to the explict flushing of the zlib compression engine during
zip encoding (via Z_SYNC_FLUSH), resulting in much less efficiency in
compression in some cases.

There's a FIXME comment in the source from 990709 indicating that it's a
workaround for a problem with recent (presumably as of that date) versions
of zlib.  Would anyone happen to have further information on the bug that
it's working around and whether or not that's still necessary?  I found some
e-mails in the archives from that timeframe but not much concrete
information.  The sample files on a web site showing the problem at the time
are, not surprisingly, no longer available.

It's true that it hurts most on small images, especially those in the Ks to
10Ks, but even larger images grow 5-10%, so if it's something that might be
removable (or perhaps conditional on a save option) it might help.

Thanks.

-- David



More information about the Image-SIG mailing list