N
niko
Posted this in the sun java forums without any replies. Posting it
here too...
---------------------------------------------------------------------------
Does anyone know what the exception "javax.imageio.IIOException:
Missing Huffman code table entry" is indicating? My code reads and
writes an image to disk using the image io APIs. Most images are ok
but for some of them, I get the exception. The images come from
external sources, usually direct from digital cameras and look fine in
any browser/viewer.
Any ideas?
This is the code:
static public void testProblem(File src, File dest, IPTCInfo info)
throws Exception {
ImageReader reader = null;
ImageWriter writer = null;
ImageInputStream iis = null;
ImageOutputStream ios = null;
BufferedImage buff = null;
IIOMetadata metadata = null;
try {
// First, find a reader for jpg which handles metdata
Iterator it = ImageIO.getImageReadersByFormatName("jpg");
while (it.hasNext() && metadata==null) {
/**
* Try this reader...
*/
reader = (ImageReader) it.next();
//Open up the ImageInputStream
iis = ImageIO.createImageInputStream(src);
if (iis!=null) {
// Set the readers stream
reader.setInput(iis);
// Read the pixels and metadata
buff = reader.read(0);
metadata = reader.getImageMetadata(0);
if (metadata==null)
iis.close();
}
}
if (metadata==null)
throw new Exception("IPTCUtil: No metadata found");
// Writing the File
writer = ImageIO.getImageWriter(reader);
IIOImage outImage = new IIOImage(buff,null, metadata);
ios = ImageIO.createImageOutputStream(dest);
writer.setOutput(ios);
writer.write(metadata,outImage,null);
} catch (Exception ex) {
throw ex;
} finally {
if (reader!=null)
reader.dispose();
if (writer!=null)
writer.dispose();
if (iis!=null)
iis.close();
if (ios!=null)
ios.close();
}
}
here too...
---------------------------------------------------------------------------
Does anyone know what the exception "javax.imageio.IIOException:
Missing Huffman code table entry" is indicating? My code reads and
writes an image to disk using the image io APIs. Most images are ok
but for some of them, I get the exception. The images come from
external sources, usually direct from digital cameras and look fine in
any browser/viewer.
Any ideas?
This is the code:
static public void testProblem(File src, File dest, IPTCInfo info)
throws Exception {
ImageReader reader = null;
ImageWriter writer = null;
ImageInputStream iis = null;
ImageOutputStream ios = null;
BufferedImage buff = null;
IIOMetadata metadata = null;
try {
// First, find a reader for jpg which handles metdata
Iterator it = ImageIO.getImageReadersByFormatName("jpg");
while (it.hasNext() && metadata==null) {
/**
* Try this reader...
*/
reader = (ImageReader) it.next();
//Open up the ImageInputStream
iis = ImageIO.createImageInputStream(src);
if (iis!=null) {
// Set the readers stream
reader.setInput(iis);
// Read the pixels and metadata
buff = reader.read(0);
metadata = reader.getImageMetadata(0);
if (metadata==null)
iis.close();
}
}
if (metadata==null)
throw new Exception("IPTCUtil: No metadata found");
// Writing the File
writer = ImageIO.getImageWriter(reader);
IIOImage outImage = new IIOImage(buff,null, metadata);
ios = ImageIO.createImageOutputStream(dest);
writer.setOutput(ios);
writer.write(metadata,outImage,null);
} catch (Exception ex) {
throw ex;
} finally {
if (reader!=null)
reader.dispose();
if (writer!=null)
writer.dispose();
if (iis!=null)
iis.close();
if (ios!=null)
ios.close();
}
}