tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Java > Image IO > How to get image width and height

How to get image width and height 

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 how to get image width and height.

stpatricks_08.gif

File Name  :  
com/bethecoder/tutorials/imageio/GetImageInfoTest2.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.imageio;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class GetImageInfoTest2 {

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

    File file = new File("C:/Temp/stpatricks_08.gif");
    BufferedImage bufImage = ImageIO.read(file);
    
    System.out.println("Width : " + bufImage.getWidth() " pixels");
        System.out.println("Height : " + bufImage.getHeight() " pixels");
        System.out.println("Transparency : " + bufImage.getTransparency());
  }

}
   

It gives the following output,
Width : 320 pixels
Height : 110 pixels
Transparency : 1


                    Print

   



Books Recommendation

 
 
bl  br