图片等比缩小,用军刀Images工具类
try {
Images.zoomScale("d:\\01.jpg", "d:\\01_s.jpg", 1024, -1, Color.white);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}//生成缩略图,设置背景色
报错
Exception in thread "main" java.lang.StackOverflowError
at org.nutz.img.Images.zoomScale(Images.java:288)
at org.nutz.img.Images.zoomScale(Images.java:229)
at org.nutz.img.Images.zoomScale(Images.java:288)
at org.nutz.img.Images.zoomScale(Images.java:229)
查代码Images 227行:
public static BufferedImage zoomScale(BufferedImage im, int w, int h, Color bgColor) {
if (w == -1 || h == -1) {
return zoomScale(im, w, h); //<<<
}
//...
}
跟到Images 287行:
public static BufferedImage zoomScale(BufferedImage im, int w, int h) {
return zoomScale(im, w, h, null); //<<<
}
发现当W或H为-1时,死循环。
下载nutz-1.r.65.jar最新版,依旧。