public static String getPicSize(String url){
URL temp;
BufferedInputStream in;
int orinWidth = 0;
int orinHeigth = 0;
FileOutputStream file;
try {
temp = new URL(url);
try {
String fileName="D:\\1.jpg";
in = new BufferedInputStream(temp.openStream());
file = new FileOutputStream(new File(fileName));
int t;
while ((t = in.read()) != -1) {
file.write(t);
}
//fileload为操作名
ParameterBlockJAI loadPB = new ParameterBlockJAI("fileload");
//指定图片文件名
loadPB.setParameter( "filename",fileName);
PlanarImage source = JAI.create( "fileload", loadPB);
//得到图像尺寸
orinWidth = source.getWidth();
orinHeigth = source.getHeight();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return orinWidth+"*"+orinHeigth;
}