引入依赖
<!--图片处理工具类-->
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
String oldDest = "C:\\Users\\19046\\Desktop\\新建文件夹 (3)";
File file = new File(oldDest);
if(!file.exists()){
System.out.println("文件夹不存在!");
}
//获取图片列表
File[] imageList = file.listFiles();
if(imageList!=null){
for (File temp : imageList) {
if(temp.isFile()){
System.out.println(temp.getAbsolutePath());
try {
Thumbnails.of(temp).scale(0.5f).outputQuality(0.25f).toFile(temp.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}