The following code works fine to write a BufferedImage
to a file in .bmp, .jpg and .png formats:
import java.awt.*;
import javax.imageio.ImageIO;
...
BufferedImage image; // assume `image` is properly initialized
File file; // assume 'file' is properly initialized to some file
String format; // This is either 'bmp', 'jpg', or 'png'; if 'tif', it fails
ImageIO.write(imageBlank, format, file); // This properly creates a file for 'bmp', 'jpg', or 'png'; not for 'tif'
However, when the format is .tif, the above code throws an exception on the write
line.
Many links suggest using the Java Advanced Imaging API to create TIFF's; some give the following link: http://java.sun.com/javase/technologies/desktop/media/jai/. However, this link does not lead to a download of JAI. Other links are either dead or circular. I don't think that JAI is included with JDK 1.7; am I correct?
Can someone either give a working link to the actual JAI download, or else tell me how to create a .tif file from a BufferedImage
using JDK 1.7?