카테고리1프로그래밍
카테고리2JAVA
제목썸네일 생성 함수
작성자고성훈
작성일2021-05-06 04:41:09
public String thumbnail(String oriFile, String thumbFile){
String str = "";
try {
//썸네일 가로사이즈
int thumbnail_width = 400;
//썸네일 세로사이즈
int thumbnail_height = 300;
//원본이미지파일의 경로+파일명
File origin_file_name = new File(oriFile);
//생성할 썸네일파일의 경로+썸네일파일명
File thumb_file_name = new File(thumbFile);
BufferedImage buffer_original_image = ImageIO.read(origin_file_name);
BufferedImage buffer_thumbnail_image = new BufferedImage(thumbnail_width, thumbnail_height, BufferedImage.TYPE_3BYTE_BGR);
Graphics2D graphic = buffer_thumbnail_image.createGraphics();
graphic.drawImage(buffer_original_image, 0, 0, thumbnail_width, thumbnail_height, null);
ImageIO.write(buffer_thumbnail_image, "jpg", thumb_file_name);
} catch (Exception e) {
str = e.toString();
}
return str;
}
수정목록