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; } |