|
@ -115,6 +115,23 @@ public final class JpgUtil {
|
115
|
115
|
Itemp = ato.filter(bufImg, null);
|
116
|
116
|
return ImageIO.write((BufferedImage) Itemp, JPG, dest);
|
117
|
117
|
}
|
|
118
|
|
|
119
|
/**
|
|
120
|
* 图片等比缩放
|
|
121
|
* @param in 输入流
|
|
122
|
* @param out 输出流
|
|
123
|
* @param maxLen 图片较长的一边
|
|
124
|
* @return
|
|
125
|
* @throws IOException
|
|
126
|
*/
|
|
127
|
public static boolean scalingZoom(InputStream in,OutputStream out, int maxLen) throws IOException{
|
|
128
|
BufferedImage bi = ImageIO.read(in);
|
|
129
|
double max = bi.getWidth()>bi.getHeight()?bi.getWidth():bi.getHeight();
|
|
130
|
double scaling = maxLen/max;
|
|
131
|
AffineTransformOp ato = new AffineTransformOp(AffineTransform.getScaleInstance(scaling,scaling), null);
|
|
132
|
Image Itemp = ato.filter(bi, null);
|
|
133
|
return ImageIO.write((BufferedImage) Itemp, JPG, out);
|
|
134
|
}
|
118
|
135
|
|
119
|
136
|
private JpgUtil() {
|
120
|
137
|
}
|