United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6488522 : PNG writer should permit setting compression level and iDAT chunk maximum size

Details
Type:
Enhancement
Submit Date:
2006-10-31
Status:
Resolved
Updated Date:
2016-08-01
Project Name:
JDK
Resolved Date:
2015-12-16
Component:
client-libs
OS:
generic
Sub-Component:
javax.imageio
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
8,9
Fixed Versions:

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
Currently the PNG compression level and iDAT chunk size are not mutable via the API. Not being able to set the iDAT size is a problem for some customers as evidenced by this issue:

https://jai-imageio-core.dev.java.net/issues/show_bug.cgi?id=95

Currently in jai-imageio the compression level and other items are settable as described here:

http://download.java.net/media/jai-imageio/javadoc/1.1/overview-summary.html#PNGImageWriteParam

                                    

Comments
FYI, Daniel Gredler <djgredler at gmail.com> made a small backport library that provides the fix and works in Java 7 and Java 8:
https://github.com/gredler/jdk9-png-writer-backport

Laurent
                                     
2016-08-01
URL:   http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/6648f64ba30a
User:  lana
Date:  2016-02-10 21:55:24 +0000

                                     
2016-02-10
URL:   http://hg.openjdk.java.net/jdk9/client/jdk/rev/6648f64ba30a
User:  prr
Date:  2015-12-16 22:39:18 +0000

                                     
2015-12-16
What means "set the iDAT chunk size" ? I did not change anything concerning buffers.

Does it seem possible to backport this fix to JDK 8 updates ?


                                     
2015-12-10
Could you sponsor this important bug fix, please ?
                                     
2015-12-10
RFR: http://mail.openjdk.java.net/pipermail/2d-dev/2015-December/006039.html
                                     
2015-12-09
I looked at PNGImageWriter class and will work on a patch soon.

Actually the Deflater is very time consuming as it uses the maximum compression (level 9):
Deflater def = new Deflater(Deflater.BEST_COMPRESSION)

I quickly tested several Deflater compression levels [0 to 9] on some huge map images:
   * total size:
      * level 1: 49.9 Mb
      * level 3: 46.9 Mb
      * level 4: 40.7 Mb
      * level 9: 37 Mb
   * write PNG time (most complex image) :
      * level 1: 8211 ms
      * level 3: 7793 ms
      * level 4: 9450 ms
      * level 9: 23562 ms

I would choose by default the level 4 to have the best compromise between speed vs time.
                                     
2015-12-02
Please re-open if
 - if fix is in progress or on the plan to fix soon
 - if this is a P3 (file as P3, not P4) 
                                     
2014-03-18
SUGGESTED FIX

Create a new ImageWriteParam subclass javax.imageio.plugins.png.PNGImageWritePatam which has a mutator and accessor for the compression level and the iDAT maximum size. The default iDAT size should be 8192 to match libpng.
                                     
2006-10-31



Hardware and Software, Engineered to Work Together