[Image-SIG] Converting images to palette mode

Evgeny Salmin evg.salmin at gmail.com
Fri Mar 13 23:03:52 CET 2009


   Recently we wrote about memory problems of PIL while converting large
number of png files to 8-bit palette format. After some number of messages
simple converting script (see in attach) takes all available memory from a
system and produces QuantizationError. After some examinating of PIL source
code we've founded that QuantizationError arrises after failed malloc. Each
new image increase memory usage, whereas this script should work in fixed
amount of memory (it processes image, then takes the next one).
I've realized that problem can be solved by applying simple patch (see
attach). After tests on huge number of png files memory consumption looks
fixed and converting works correct.
I'd like to know PIL author's opinion. Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090314/f5f382a0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PIL_mem_leak.diff
Type: application/octet-stream
Size: 348 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090314/f5f382a0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: to_8bit.py
Type: application/octet-stream
Size: 2160 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090314/f5f382a0/attachment-0001.obj>

More information about the Image-SIG mailing list