public static Map<String,Integer> getImageWH(byte[] bytes ){
Map<String,Integer> map = new HashMap<String,Integer>();
if(bytes==null){
map.put("w", 0);
map.put("h", 0);
return map;
}
try{
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
BufferedImage bi = ImageIO.read(stream);
int srcWidth = bi.getWidth(); // 源图宽度
int srcHeight = bi.getHeight(); // 源图高度
map.put("w", srcWidth);
map.put("h", srcHeight);
}catch(Exception ex){
logger.error("getImageWH get image w and h has error!");
ex.printStackTrace();
map.put("w", 0);
map.put("h", 0);
return map;
}
return map;
}
Map<String,Integer> map = new HashMap<String,Integer>();
if(bytes==null){
map.put("w", 0);
map.put("h", 0);
return map;
}
try{
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
BufferedImage bi = ImageIO.read(stream);
int srcWidth = bi.getWidth(); // 源图宽度
int srcHeight = bi.getHeight(); // 源图高度
map.put("w", srcWidth);
map.put("h", srcHeight);
}catch(Exception ex){
logger.error("getImageWH get image w and h has error!");
ex.printStackTrace();
map.put("w", 0);
map.put("h", 0);
return map;
}
return map;
}