How to Count Images in a TIFF File with Oracle JDK

import static java.lang.System.out;

import java.util.Iterator;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;

public final class TiffSample {

  public static void main(final String[] args) throws Exception {
    final Iterator<ImageReader> it = ImageIO.getImageReadersByFormatName("tiff");

    if (it.hasNext()) {
      final ImageReader reader =;

      final DataInput in = new FileImageInputStream(new File("sample.tiff"));





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s