diegorep / pypng

Automatically exported from code.google.com/p/pypng
0 stars 0 forks source link

PNG filtering is not exploited. #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Any PNG file created always uses a type 0 filter for every scanline.

This is a problem, because filtering can greatly help compression.

Original issue reported on code.google.com by d...@pobox.com on 16 Mar 2009 at 12:18

GoogleCodeExporter commented 8 years ago
I am experiencing a problem with pypng, where png.Writer(x, x, compression=XX) 
gives
me the same output file sizes for all different compression levels. Opening a 
file
with, for example, imagej and compressing it with level nine compression 
results in
much smaller files. I guess this bug is responsible for this behaviour, but I 
am not
quite sure, as I don't know much about image processing... ( I am using the 
0.0.11
release)
Is there a chance to get this old bug fixed (if it covers my problem)?

Original comment by grimmw...@german-borg.de on 18 Jan 2010 at 2:15

GoogleCodeExporter commented 8 years ago
@grimmwolf: Filtering could be the problem, or it could be something else.

Do you have an image that you could attach in a comment?  Preferably one output 
by imagej, and then I can 
see what PyPNG makes of it?

I will in any case investigate whether the compression option actually does 
anything (it should affect the zlib 
compression, but it's possible that there's a bug there).

I should say though... if PyPNG does ever implement filtering on the PNG files 
that it creates it will be a _lot_ 
slower to save.

Original comment by d...@pobox.com on 19 Jan 2010 at 8:21

GoogleCodeExporter commented 8 years ago
Most ways of implementing filters will be quite slow in Python, however, there 
is one idea that might be 
reasonably fast (and hence worth implementing):

It should be quick to test whether this scanline is identical to the previous 
one (if they are both lists, then A==B 
can be used).  That being the case, the "up" filter can be applied to give a 
constant result.

For most "real" images this is unlikely to give any benefit, but there are 
plenty of artificial images where it should 
give some benefit.

Original comment by d...@pobox.com on 5 Mar 2010 at 3:27