Java 9 TIFF Image I/O plugins

In earlier version of Java, Image I/O Framework javax.imageio provides a standard way to plug-in image codecs for some formats such as PNG and JPEG. But TIFF is still missing from this set. It was packaged in before. Java 9 TIFF Image I/O plugins has a new package called javax.imageio.plugins.tiff which is renamed from

In this article, we’re gonna take a look at that package and test a simple example.

I. javax.imageio.plugins.tiff

The package contains some classes that support the built-in TIFF reader and writer plug-ins. It includes:
– Some classes representing common additional tags and the set of tags found in baseline TIFF specification, Exif IFD, TIFF-F (RFC 2036) file, GeoTIFF IFD.
TIFFImageReadParam: an extension of ImageReadParam which can specify which metadata tags are allowed to be read and set some destination properties.

For more details, please visit:
javax.imageio.plugins.tiff – Package Summary
TIFF Metadata Format Specification and Usage Notes.

II. Example

In the example, we will read an input stream of TIFF image, set its metadata tags and destination offset. Then we write data after processing to another TIFF image as result.

This is source code:

The input TIFF image with the size[240,240] will be read by ImageReader.
By default, TIFFImageReadParam adds 4 TagSets: BaselineTIFFTagSet, FaxTIFFTagSet, ExifParentTIFFTagSet, GeoTIFFTagSet in its constructor method. We remove 2 TagSets, then set offset in the destination image by [20,20]. So the image after using read() method will be shifted and increase its height and width by 20 pixels.

The image below shows details inside ImageReader tiffReader variable:

Run the code, console window shows:

And this is the exported TIFF image:
newTiffImage.tiff - click to download

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *