Creating a jpeg file: "no preview available"
When I create a jpeg file within a java program, and then (I'm using Windows) go to look at it, I can see it just fine with the thumbnail in my Windows folder, but if I open the file with the Windows Picture and Fax Viewer, it says "no preview available," and doesn't display the image.
Here's my code:
Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter) iter.next();
// instantiate an ImageWriteParam object with default compression options
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionQuality(1); // an integer between 0 and 1
// 1 specifies minimum compression and maximum quality
FileImageOutputStream output = new FileImageOutputStream(file);
IIOImage im = new IIOImage(image, null, null);
writer.write(null, im, iwp);
writer = (ImageWriter) iter.next(); // Force closing of the writer
Btw, I get an exception on that last line (the "next" call), NoSuchElementException. Maybe it's related?