Thumbnailator库(高质量缩略图)简单总结
程序员文章站
2022-06-10 09:39:01
...
参考链接:https://blog.csdn.net/lcj_star/article/details/76637931?utm_source=blogxgwz2
1、github:https://github.com/coobird/thumbnailator
2、pom.xml
3、按比例缩放图片
1、github:https://github.com/coobird/thumbnailator
2、pom.xml
<dependency> <groupId>net.coobird</groupId> <artifactId>thumbnailator</artifactId> <version>0.4.8</version> </dependency>
3、按比例缩放图片
public static void scale(String sourceImagePath, String targetImagePath, double scale) throws RuntimeException { try { Thumbnails.of(sourceImagePath). // scalingMode(ScalingMode.BICUBIC). scale(scale). // 图片缩放scale%, 不能和size()一起使用 outputQuality(scale). // 图片质量压缩scale% toFile(targetImagePath); } catch (IOException e) { throw new RuntimeException(e); } }