Here you can find the source of resampleImage(BufferedImage image, int height)
public static BufferedImage resampleImage(BufferedImage image, int height)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; public class Main { public static BufferedImage resampleImage(BufferedImage image, int height) { double mult = height / ((double) image.getHeight()); Image unbufScaledImage = image.getScaledInstance((int) (mult * image.getWidth()), height, Image.SCALE_DEFAULT); BufferedImage scaledImage = new BufferedImage(unbufScaledImage.getWidth(null), unbufScaledImage.getHeight(null), BufferedImage.TYPE_BYTE_GRAY); Graphics g = scaledImage.createGraphics(); g.drawImage(unbufScaledImage, 0, 0, null); g.dispose();//from w ww . java2 s .com return scaledImage; } }