Here you can find the source of compressPhoto(Image originImg, int newWidth, int newHeight)
public static Image compressPhoto(Image originImg, int newWidth, int newHeight)
//package com.java2s; //License from project: Open Source License import java.awt.Image; import java.awt.image.BufferedImage; public class Main { public static Image compressPhoto(Image originImg, int newWidth, int newHeight) { Image newImg = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB); newImg.getGraphics().drawImage(originImg.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH), 0, 0, null);/*from w ww . ja v a 2 s . com*/ return newImg; } }