1. 썸네일 라이브러리, Thumbnailator
- 다운로드 : https://mvnrepository.com/artifact/net.coobird/thumbnailator/0.4.8
2. Thumbnailator 사용방법
- sourceRegion()
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg");
Thumbnails
.of(new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg"))
.sourceRegion(Positions.TOP_CENTER, 200, 200)
.size(200, 200)
.toFile(new File("C:\\Users\\user\\Desktop\\thumb", "result.jpg"));
}
- forceSize()
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg");
Thumbnails
.of(new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg"))
.forceSize(200, 200)
.toFile(new File("C:\\Users\\user\\Desktop\\thumb", "result.jpg"));
}
- crop()
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg");
Thumbnails
.of(new File("C:\\Users\\user\\Desktop\\thumb", "origin.jpg"))
.size(200, 200)
.crop(Positions.CENTER)
.toFile(new File("C:\\Users\\user\\Desktop\\thumb", "result.jpg"));
}