Customer login  |   Contact us
Home Company Products Support Purchase
Forum Home » ObjectPlanet Developer forum

Topic: PngEncoder - Bug with COLOR_INDEXED files - Extra compression data
Replies: 0   Pages: 1  


Back to Topic List Back to Topic List
Replies: 0   Pages: 1  
ecd

Posts: 1
Registered: Mar 29, 2012
PngEncoder - Bug with COLOR_INDEXED files - Extra compression data
Posted: Mar 29, 2012 2:10 AM
  Reply
image.png (0.1 K)
output.png (0.8 K)

The images produced by PngEncoder where the colorType is PngEncoder.COLOR_INDEXED seem to have extraneous compressed data, as reported by libpng:

libpng warning: Extra compressed data
libpng warning: Extra compression data

I've been able to reproduce this with a minimal test case using PngEncoder 2.0.2. I've created a 10x10 8-bit palette PNG, filled with green pixels using the following SNG file (SNG is used here for simplicity):

#SNG: from image.png
IHDR {
width: 10; height: 10; bitdepth: 8;
using color palette;
}
PLTE {
(0, 255, 0) # green
}
IMAGE {
pixels hex
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00
}

The corresponding PNG file, image.png, is attached. I then ran the following code:

public static void main(String args[]) throws Exception {
BufferedImage sourceImage = ImageIO.read(new File("src/main/resources/image.png"));
new PngEncoder(PngEncoder.COLOR_INDEXED).encode(sourceImage, new FileOutputStream("src/main/resources/output.
}

The file it produces, output.png, looks correct in many png rendering programs, including available web browsers. However, libpng reports warnings when reading it. I use either pngcrush or SNG (to convert the output.png to output.sng) to see this effect:

[ecd@work ]$ sng output.png
libpng warning: Extra compressed data
libpng warning: Extra compression data
[ecd@work ]$

I've also seen some COLOR_INDEXED encoded files which cause libpng to give error messages. These files are renderable in some web browsers but not others (including Internet Explorer). I do not yet have a reproducible test case for this scenario. I plan on doing that later.



© 1998-2017 ObjectPlanet, Inc. Øvre Slottsgate 5, 0157 Oslo, Norway Tel (+47) 2233 3360 | Fax (+47) 2233 3361