Hi all,
In one of our application we are using following JAI code to convert TIFF images to PNG images.
PNGEncodeParam param = new PNGEncodeParam.Palette();
TIFFDecodeParam inparam = new TIFFDecodeParam();
inparam.setDecodePaletteAsShorts(true);
int iTotalPages = 0;
try {
InputStream instream = new ByteArrayInputStream(arrImage);
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", instream, inparam);
iTotalPages = dec.getNumPages();
for (int iPageNo = 0; iPageNo < iTotalPages; iPageNo++) {
RenderedImage image = dec.decodeAsRenderedImage(iPageNo);
OutputStream os = new FileOutputStream(localDirectory + "/" + Image + "_" + (iPageNo + 1) + ".png");
ImageEncoder encoder = ImageCodec.createImageEncoder("PNG", os, param);
encoder.encode(image);
}
}
catch (Exception objException) { }
Note: arrImage is a byte array passed after reading the TIFF file.
This program finished till the last line of code but hangs almost everytime. after looking at the Thead dump I saw one
thread that is still waiting for the condition and it looks like this
at com sun media jai codecTempFileCleanupThread.run(FileCacheSeekableStream.java:321)
it looks like the internal Thread spawned by JAI apis to clean temporary files. the JAI version we are using is 1.1.2_01.
Java version is J2RE 1.4.2 IBM AIX 5L for PowerPC (64 bit JVM) build caix64142-20060421 (SR5).
If anybody has any insight in the issue, please help.
Thanks
Ashish