Hi,
some of you may know that we're unable to read PNG without native
JAI components installed, and we get the following stack trace:
...
javax.imageio.IIOException: I/O error reading PNG header!
at com.sun.imageio.plugins.png.PNGImageReader.readHeader(PNGImageReader.java:296)
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:620)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1309)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1530)
at javax.imageio.ImageReader.read(ImageReader.java:919)
at PngImageBreak.main(PngImageBreak.java:16)
Caused by: javax.imageio.IIOException: Bad length for IHDR chunk!
at com.sun.imageio.plugins.png.PNGImageReader.readHeader(PNGImageReader.java:232)
Ok, today I tried to reproduce it outside Geoserver, by forcing the
usage of the pure java image i/o png reader. At first I could not, until
I noticed that Geoserver is using the high performance image streams
Geosolution written. And it turns out, the sample app breaks the same way as Geoserver only if I use those, so the bug must be in the reader.
The sample app is:
import it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl;
import java.io.File;
import java.io.IOException;
import com.sun.imageio.plugins.png.PNGImageReader;
public class PngImageBreak {
public static void main(String args) throws IOException {
PNGImageReader reader = new PNGImageReader(null);
File file = new File("c:\\progetti\\gisData\\bluemarble\\garda1.png");
FileImageInputStreamExtImpl iis = new FileImageInputStreamExtImpl(file);
// ImageInputStream iis = ImageIO.createImageInputStream(new FileInputStream(file));
reader.setInput(iis);
reader.read(0);
}
}
If you use the standard input streams it reads the image fine, using
the FileImageInputStreamExtImpl one, boom.
I also feel a little uneasy that the custom streams source code has
been removed from the geotools svn (or else, we still have it
in 2.3.x, but don't know if it's up to date).
Would it be possible to have that code back and hosted in gt2 since
we depend on it? Or handled as a separate open source project anyways.
Cheers
Andrea