Dan Nissenbaum
Dan Nissenbaum

Reputation: 13928

Save a BufferedImage as a TIFF file?

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?

Upvotes: 4

Views: 8738

Answers (2)

Joni
Joni

Reputation: 111359

This project apparently adds TIFF read and write capabilities to ImageIO: http://java.net/projects/imageio-ext

If you are looking for JAI 1.1.3: Where can I download Jai and Jai-imageio?

Upvotes: 3

Related Questions