tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Java > Image IO > How to get image readers by format name

How to get image readers by format name 

Java Image IO provides pluggable architecture for accessing images transparently. It is simple, flexible and allows us to plugin various image readers and writers with ease. The following example shows getting the registered image readers for given image format name.

File Name  :  
com/bethecoder/tutorials/imageio/GetImageReadersByFormatNameTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.imageio;

import java.io.IOException;
import java.util.Iterator;

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

public class GetImageReadersByFormatNameTest {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {

    Iterator<ImageReader> imgReaders = ImageIO.getImageReadersByFormatName("bmp");
    ImageReader reader = null;
    
    while (imgReaders.hasNext()) {
      reader = imgReaders.next();
      
      System.out.println("Format : " + reader.getFormatName());
      System.out.println("Reader class : " + reader.getClass());
      System.out.println("Tumbnails : " + reader.readerSupportsThumbnails());
      System.out.println("Can read raster : " + reader.canReadRaster());
    }
  }

}
   

It gives the following output,
Format : bmp
Reader class : class com.sun.imageio.plugins.bmp.BMPImageReader
Tumbnails : false
Can read raster : true



 
  


  
bl  br