public static BufferedImage resizeToWidth ( BufferedImage originalImage , int widthOut ) { int width = originalImage . getWidth ( ) ; int height = originalImage . getHeight ( ) ; int widthPercent = ( widthOut * 100 ) / width ; int newHeight = ( height * widthPercent ) / 100 ; BufferedImage resizedImage = new BufferedImage ( widthOut , newHeight , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = resizedImage . createGraphics ( ) ; g . drawImage ( originalImage , 0 , 0 , widthOut , newHeight , null ) ; g . dispose ( ) ; return resizedImage ; }
Resizes an image to the specified width changing width in the same proportion