473,573 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing PNG with pure Python

Just in case anybody has the same problem, here's my first attempt at
implementing a subset of the PNG spec in pure Python. I license it to
you under the terms of the GNU GPL.

http://trac.browsershots.org/browser...b/image/png.py

It encodes RGB images with 24 bits per pixel into PNG, using only the
modules sys, zlib and struct. These are all included in the base
distribution of Python. You don't need gd or imlib.

I have done a little testing, and my implementation processes 8 megs of
RGB input in 0.6 seconds. With Adam7 interlacing enabled, it takes 10
times longer.

I would really appreciate any feedback and suggestions for improvement.

Cheers,
Johann

Jun 9 '06 #1
17 8713
> You should really also include the alpha channel. Without that, PNG is
crippled IMHO.


I have now added simple transparency (marking one color as transparent
with a tRNS chunk). If anybody wants full alpha channel support, ask
kindly or send me a patch. I would like to avoid duplicating all the
functions, so maybe we should introduce a parameter to switch between 3
and 4 bytes per pixel.

Cheers,
Johann

Jun 9 '06 #2
On Fri, 09 Jun 2006 07:43:21 -0400, Johann C. Rocholl
<jc*******@goog lemail.com> wrote:
here's my first attempt at
implementing a subset of the PNG spec in pure Python. I license it to
you under the terms of the GNU GPL.
http://trac.browsershots.org/browser...b/image/png.py


It's your code, so you get to license it.
But if you wish to solicit patches,
a more Pythonic license is IMHO more likely
to prove fruitful.

Alan Isaac
Jun 9 '06 #3
Em Sex, 2006-06-09 √*s 12:30 -0400, Alan Isaac escreveu:
It's your code, so you get to license it.
But if you wish to solicit patches,
a more Pythonic license is IMHO more likely
to prove fruitful.


"Pythonic license"? That's new to me. I can figure out what a
"Python-like license" is, but I'm clueless about a "Pythonic license".

--
Felipe.

Jun 9 '06 #4
> Em Sex, 2006-06-09 ŗs 12:30 -0400, Alan Isaac escreveu:
It's your code, so you get to license it.
But if you wish to solicit patches,
a more Pythonic license is IMHO more likely
to prove fruitful.

"Felipe Almeida Lessa" <fe**********@g mail.com> wrote in message
news:ma******** *************** *************** *@python.org... "Pythonic license"? That's new to me. I can figure out what a
"Python-like license" is, but I'm clueless about a "Pythonic license".

http://www.panikon.com/phurba/alteng/i.html
hth,
Alan Isaac
Jun 9 '06 #5
Alan Isaac schrieb:
It's your code, so you get to license it.
But if you wish to solicit patches,
a more Pythonic license is IMHO more likely
to prove fruitful.


What license would you suggest? After some reading at [1] and [2] and
[3], I found that the Academic Free License (version 2.1) and the
Apache License (version 2.0) are considered helpful for contributions
to the Python Software Foundation.

So far, I haven't used either of these licenses for my own code, and
after a little reading the AFL seems okay for me. I would perhaps
consider the LGPL [4] as an alternative because it is less restrictive
than the GPL.

Thoughts or links, anybody?

Cheers,
Johann

[1] http://www.python.org/moin/PythonSof...tionLicenseFaq
[2] http://www.python.org/psf/records/bo...es/2004-11-09/
[3] http://www.python.org/psf/contrib/
[4] http://www.gnu.org/licenses/lgpl.html

Jun 9 '06 #6

"Johann C. Rocholl" <jc*******@goog lemail.com> wrote in message
news:11******** **************@ f6g2000cwb.goog legroups.com...
What license would you suggest?


I recommend that you choose the license that will best achieve
your long run goals for the code. As I understand them, and
as I understand your application and software development,
this implies something like the MIT license:
http://www.opensource.org/licenses/mit-license.php
I believe that the MIT license maximizes the likelihood that
a small scale application will receive useful patches, as long
as you actively incorporate patches.

You may reach other conclusions for many reasons ...

Cheers,
Alan Isaac
Jun 9 '06 #7
The MIT license is enticingly short and simple, thank you for the tip.

I have now decided to license my project (including the pure python PNG
library) under the Apache License 2.0 which is less restrictive than
the GPL in terms of sublicensing. The Apache License looks modern and
well-maintained to me. My project runs on Apache, so there is some
context there as well. Also, this change will simplify things if I ever
want to contribute some of the code to the Python Software Foundation.

Cheers,
Johann

Jun 10 '06 #8
> Just in case anybody has the same problem, here's my first attempt at
implementing a subset of the PNG spec in pure Python. I license it to
you under the terms of the GNU GPL.
Update: the code is now licensed under the Apache License 2.0.
http://trac.browsershots.org/browser...b/image/png.py


Update: the module has moved to its own package, with its own setup.py:

http://trac.browsershots.org/browser/trunk/pypng
http://svn.browsershots.org/trunk/pypng/

Cheers,
Johann

Jun 12 '06 #9
Johann C. Rocholl wrote:
The MIT license is enticingly short and simple, thank you for the tip.

I have now decided to license my project (including the pure python PNG
library) under the Apache License 2.0 which is less restrictive than
the GPL in terms of sublicensing.


But it is also incompatible with the GPL:

http://www.fsf.org/licensing/license...atibleLicenses

It's obviously your decision about how you license your own code, but
I'd advise you to disregard the "Pythonic license" rhetoric, whatever
that means: Python's original licence was regarded as not being enough
of a licence by some lawyers (that's what some people refer to as the
original Python licence); subsequent licences aren't recommended for
application to any other works (like various licences of the Python
code over the years); despite advocacy for permissive licences by some
parties, there exist numerous successful GPL'd and LGPL'd Python
projects (meaning that projects licensed in such a way are not lesser
members of the community). Moreover, any licensing gymnastics
undertaken by the PSF did involve various extra somersaults to remain
GPL-compatible, meaning that even people who favour permissive licences
regard "licence interoperabilit y" positively.

If you're convinced that a permissive licence suits your code best,
please consider something whose side-effects you understand. If the
additional patent grant or licence termination clauses (which the FSF
don't regard as a bad thing, just something incompatible with the
current GPL/LGPL) are specifically what you want, then the Apache
Licence may be what you're after; otherwise, you should choose
something less baroque and better understood, perhaps from this list:

http://www.fsf.org/licensing/license...atibleLicenses

Yes, one of the best places to find out about non-FSF licences is
actually the FSF themselves, undermining various myths some people like
to put forward.

Paul

Jun 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2674
by: Ravi | last post by:
Hi, I did some googling, and found that there doesn't seem to be a pure python MySQL communication module. There is one for perl however, Net::MySQL. I was wondering if there was a specific reason why something similar hasn't been implemented in Python, a limitation of the language or libraries perhaps? I briefly scanned through the perl...
11
1950
by: Brett C. | last post by:
For my thesis (once the bloody thing stops throwing bugs at me) I am going to need to collect stats on the frequency that atomic types in local variables are applied to various opcodes and methods. That means that I need something to collect stats off of. So I am trying to come up with a list of projects I can use to get my stats from. ...
5
2663
by: Fuzzyman | last post by:
Python 2.4 is built with Microsoft Visiual C++ 7. This means that it uses msvcr7.dll, which *isn't* a standard part of the windows operating system. This means that if you build a windows installer using distutils - it *requires* msvcr7.dll in order to run. This is true even if your package is a pure python package. This means that when...
5
6002
by: Fernando Perez | last post by:
Hi all, by reading through the docs, the func_closure attribute of function objects is listed as writable. Yet, nowhere does it say _how_ to write to it. I am trying to do a run-time modification of a function's closure, where I want to modify the value of one of the variables in the closure. But the closure appears as a tuple of 'cell'...
102
6999
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality of its documentation, it is a impeccability. it has or possesses properties of:
13
2145
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
3
3691
by: Paul Moore | last post by:
I'd like to write some scripts to analyze and manipulate my music files. The files themselves are in MP3 and FLAC format (mostly MP3, but FLAC where I ripped original CDs and wanted a lossless format). I've no idea what form of tags are used in the files (ID3v1, ID3v2, OGG, APE, ...) I just used whatever the program that set them up used. I'm...
12
3119
by: betabrain.honshu | last post by:
Hi Folks, for those of you who are familiar with the micropledge.com project, here is a good opportunity to spend or earn something: http://micropledge.com/projects/pysalsa20 I know that the details of this project are still a bit unclear, but that is something we could discuss. By the way, the end result should look like it's a part of...
28
2427
by: n00m | last post by:
Both codes below read the same huge(~35MB) text file. In the file 1000000 lines, the length of each line < 99 chars. Stable result: Python runs ~0.65s C : ~0.70s Any thoughts?
0
7746
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main...
0
7668
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7983
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8179
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5257
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2166
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
992
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.