|
@@ -2,6 +2,8 @@ package com.qmth.paper.library.common.util;
|
|
|
|
|
|
|
|
|
import net.coobird.thumbnailator.Thumbnails;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.imageio.ImageReadParam;
|
|
@@ -19,6 +21,8 @@ import java.util.Iterator;
|
|
|
*/
|
|
|
public class ImageUtil {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(ImageUtil.class);
|
|
|
+
|
|
|
/**
|
|
|
* 裁剪图片
|
|
|
*
|
|
@@ -83,7 +87,7 @@ public class ImageUtil {
|
|
|
}
|
|
|
Thumbnails.of(sourceFile).scale(0.8).rotate(rotate).toFile(outFile);
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
}
|
|
|
return outFile;
|
|
|
}
|
|
@@ -97,7 +101,13 @@ public class ImageUtil {
|
|
|
Thumbnails.of(inputStream).scale(1).rotate(rotate).outputQuality(1).toFile(outFile);
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ }
|
|
|
}
|
|
|
return outFile;
|
|
|
}
|