Skip to main content

[JAI-IMAGEIO] CLibPngImageReader slower than the pure java one?

2 replies [Last post]
Anonymous

Hi,
I'm playing with an image mosaic made of 39 4000x4000
png files. I made a very simple test that scans thru
them and forces image decoding by requesting the only
tile in the raster:

import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;

import javax.media.jai.JAI;
import javax.media.jai.ParameterBlockJAI;

import tilecachetool.TCTool;

public class PngMemoryTest {
public static void main(String[] args) throws IOException {
new TCTool();
File dir = new File("C:/progetti/gisData/pngMosaicReserved");
File[] pngs = dir.listFiles(new FilenameFilter() {

public boolean accept(File dir, String name) {
return name.endsWith(".png");
}

});
long start = System.currentTimeMillis();
System.out.println("Total pngs: " + pngs.length);
for (File file : pngs) {
System.out.println(file.getName());
ParameterBlockJAI pbj = new ParameterBlockJAI("ImageRead");
pbj.setParameter("Input", file);
// pbj.setParameter("Reader", new
PNGImageReaderSpi().createReaderInstance());
RenderedImage ri = JAI.create("imageRead", pbj);
Raster r = ri.getTile(0, 0);
}
System.out.println("Done in " + (System.currentTimeMillis() -
start) / 1000.0);
}
}

If you try to run it with my dataset with the default reader (which
happens to be the clib one) the thing bombs for an out of memory
after a few images (don't know why... nothing is kept in memory
forcefully). Anyways, upping memory to 128MB allows it to complete.
Now, a few timings:
* using the default clib reader: 11.3s
* uncommenting the pure java png reader param: 8.2s
* pure java png reader + server jvm: 7.5s

This is on Windows XP, jdk 1.6.0_03, latest stable jai and jai
image i/o, intel core 2 duo e6400, 2gb memory.

It seems to me there is no good reason to use the clib png reader...
is there any way to disable the clib one globally?

Oh, btw, I cannot share the png mosaic I'm using, but I guess you'd
get the same results with any synthetically generated one...

Cheers
Andrea

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
James Cheng

On 2007/12/27 02:43 AM, Andrea Aime wrote:
> It seems to me there is no good reason to use the clib png reader...
> is there any way to disable the clib one globally?

-Dcom.sun.media.imageio.disableCodecLib=true

or remove/rename clibwrapper_jiio.jar.

Thanks,
-James

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

Andrea Aime

James Cheng ha scritto:
> On 2007/12/27 02:43 AM, Andrea Aime wrote:
>> It seems to me there is no good reason to use the clib png reader...
>> is there any way to disable the clib one globally?
>
> -Dcom.sun.media.imageio.disableCodecLib=true

Hum, no, that's not what I was looking for :)
The issue is that I want to disable png, but keep around all
of the others (a quick tests shows that the native jpeg reader
is for example more than 2 times faster than the pure java
one).

Anyways, a colleague of mine popped up in the meantime and
suggested a way to un-register only the png reader
(we already had this functionality in our library,
I just did not know it was there).
For reference, the library is GeoTools and the code is here:
http://svn.geotools.org/geotools/trunk/gt/modules/library/coverage/src/m...
(see the allowNativeCodec method).

Cheers
Andrea

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net