썸네일 이미지 폭 자바 (해상도 변경)내가 thunbnail 이미지를 만들고 싶어
이 내 코드를 만들
public static void createImage(String loadFile, String saveFile)throws IOException{
File load_image = new File(loadFile); //가져오는거
FileInputStream fis = new FileInputStream(load_image);
File save = new File(saveFile); // 썸네일
BufferedImage bi = ImageIO.read(fis);
int width = bi.getWidth();
int height = bi.getHeight();
int maxWidth=0;
int maxHeight=0;
if(width>height){
maxWidth = 1280;
maxHeight = 720;
}else{
maxWidth = 720;
maxHeight = 1280;
}
if(width > maxWidth){
float widthRatio = maxWidth/(float)width;
width = (int)(width*widthRatio);
height = (int)(height*widthRatio);
}
if(height > maxHeight){
float heightRatio = maxHeight/(float)height;
width = (int)(width*heightRatio);
height = (int)(height*heightRatio);
}
BufferedImage thu = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = thu.createGraphics();
g2.drawImage(bi, 0, 0, width, height, null);
ImageIO.write(thu, "jpg", save);
}
가끔 내 이미지 색상이 이미지 예를
예기치 않은 색상 로 변경첫 번째는 기원
초 축소판
내가 왜 ... 내가 실수 곳 몰라입니까 ??
도움 제발 ...
관련 : http://stackoverflow.com/questions/13072312/jpeg-image-color-gets-drastically-changed- after-just-imageio-read-and-imageio, http://stackoverflow.com/questions/4386446/problem-using-imageio-write-jpg-file – Marco13