最近在公司研究OCR技术
获取图片大小及长宽
public static Map getImageHW(String path){
File picture = new File(path);
BufferedImage sourceImg = null;
try {
sourceImg = ImageIO.read(new FileInputStream(picture));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Map<String,Integer> map=new HashMap<String,Integer>();
map.put("length", (int) (picture.length()/1024));
map.put("width", sourceImg.getWidth());
map.put("height", sourceImg.getHeight());
return map;
}
截取图片指定位置
package com.util;
import java.awt.Rectangle