Issue 29 in pulpcore: Allow compression level to be passed into PNGWriter

0 views
Skip to first unread message

codesite...@google.com

unread,
Nov 9, 2009, 1:57:28 PM11/9/09
to pulp...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 29 by daniel.watling: Allow compression level to be passed into
PNGWriter
http://code.google.com/p/pulpcore/issues/detail?id=29

It would be nice to allow the setting of the compression level when using
PNGWriter instead of defaulting to no compression.

I've attached a patch that will add a second (optional) parameter to the
PNGWriter.write method. The value for this second parameter can be any of
the compression levels found in "Deflater". The default is no compression.

Attachments:
pngwriter.compression.patch 1.6 KB

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Nov 9, 2009, 6:07:21 PM11/9/09
to pulp...@googlegroups.com

Comment #1 on issue 29 by brackeen: Allow compression level to be passed
into PNGWriter
http://code.google.com/p/pulpcore/issues/detail?id=29

This is incorrect because the PNG format specifies "At present, only
compression method 0 (deflate/inflate
compression with a sliding window of at most 32768 bytes) is defined.". So,
1) the default should use
Deflater.DEFAULT_COMPRESSION and 2) the compression method byte should
always be 0. Also, the new write()
method should throw an exception if the compression level is not 1-9 or -1.

Unfortunately, even with compression level 9, the compression won't be as
good as the PNG encoder provided in
tools/assettools/png which does analysis and optimization.

Dan Watling

unread,
Nov 10, 2009, 1:47:48 PM11/10/09
to PulpCore
Ah, I misread 'compression method' as 'compression level'.

Is there any specific exception that should be thrown? I've changed
the source I have locally to throw a RuntimeException to maintain
backwards compatibility with existing apps. If there is anything
specific I can make the change and resubmit a patch.

Originally, I was using the PNGWriter to upload a screenshot to my
server when necessary, but as you pointed out, the compression level
turned out to not be that great. I ended up creating a JPEGWriter
class and that works much better (~50k versus ~500k). The source for
it was yanked from an existing source (LGPL) after doing a Google
search but modified a little to support CoreImage. If you'd like I can
post that as well.

-Dan

On Nov 9, 5:07 pm, codesite-nore...@google.com wrote:
> Comment #1 on issue 29 by brackeen: Allow compression level to be passed  
> into PNGWriterhttp://code.google.com/p/pulpcore/issues/detail?id=29

David Brackeen

unread,
Nov 11, 2009, 12:12:51 PM11/11/09
to pulp...@googlegroups.com
Yeah if you want to send it. If it uses ImageIO or LGPL code we can put it in 'contrib'.
Reply all
Reply to author
Forward
0 new messages