4

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?

Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181

2 Answers2

3

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?

Community
  • 1
  • 1
Joni
  • 108,737
  • 14
  • 143
  • 193
  • Imageio-ext moved to: [https://github.com/geosolutions-it/imageio-ext](https://github.com/geosolutions-it/imageio-ext) – Marek Podyma Jun 22 '15 at 06:36
  • This is not satisfactory answer, provide some solution to specific problem instead of illustrating tools and libraries. – prem30488 Jul 28 '16 at 05:58