Java examples for 2D Graphics:Image
get Img Width
//package com.java2s; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class Main { public static int getImgWidth(File file) { InputStream is = null;/* ww w.ja v a 2 s .co m*/ BufferedImage src = null; int ret = -1; try { is = new FileInputStream(file); src = javax.imageio.ImageIO.read(is); ret = src.getWidth(null); // ?????? is.close(); } catch (Exception e) { e.printStackTrace(); } return ret; } }