Here you can find the source of getSize(byte[] data)
public static Dimension getSize(byte[] data)
//package com.java2s; //License from project: LGPL import java.awt.Dimension; import java.awt.Image; import javax.swing.ImageIcon; public class Main { public static Dimension getSize(byte[] data) { ImageIcon ii = new ImageIcon(data); Image img = ii.getImage(); return new Dimension(img.getWidth(null), img.getHeight(null)); }//w w w. ja v a2 s . co m }