[Python-Dev] Add pure python PNG writer module to stdlib?

Bob Ippolito bob at redivi.com
Sun Jun 11 11:11:34 CEST 2006

On Jun 10, 2006, at 10:52 PM, Johann C. Rocholl wrote:

>>> Does anybody think it could go into stdlib before the feature  
>>> freeze for
>> 2.5?
>> Nope.  To get added to the stdlib there needs to be support from the
>> community that the module is useful and best-of-breed.  Try  
>> posting on
>> c.l.py and see if people pick it up and like it.  No way that is  
>> going to
>> happen before b1.  But there is always 2.6 .
> That's what I thought. My remote hope was that there would be
> immediate concensus on python-dev about both the 'useful' and
> 'best-of-breed' parts. Anybody else with a +1? ;-)
> Seriously, it's totally fine with me if the module doesn't make it
> into 2.5, or even if it never makes it into stdlib. I'm just offering
> it with some enthusiasm.

The best way to do this would be to make it available as its own  
package. Give it a setup.py, stick it on CheeseShop, etc.

For performance and memory usage reasons it would probably make sense  
to take an iterator that returns a scanline at a time. The current  
implementation does a lot more allocations than it needs to (full  
image, then one str per scanline). It also asserts type is str, when  
a buffer or mmap object would work perfectly well otherwise. If  
reading from a file or something you could skip the full allocation  
and a lot of memcpy by reading a scanline at a time.

I'd also like to see RGBA support as well. Often the reason for  
choosing png over other lossless formats is its support for alpha.  
For your use case it's irrelevant, but there are many use cases that  
need the alpha channel.

But to reiterate, further discussion of this really belongs on c.l.py  
for now...


More information about the Python-Dev mailing list