Java has a rich Image manipulation layer. The following code shows how you can scale an input BufferedImage.

import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import java.io.File;

import java.net.URI;
import java.net.URL;

import javax.imageio.ImageIO;

public class ImageUtil
{
    public static BufferedImage scale(BufferedImage pImage, int pWidth, int pHeight)
    {
        int type = pImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : pImage.getType();
        BufferedImage resizedImage = new BufferedImage(pWidth, pHeight, type);
        Graphics2D graphics = resizedImage.createGraphics();
        graphics.setComposite(AlphaComposite.Src);

        graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        graphics.drawImage(pImage, 0, 0, pWidth, pHeight, null);
        graphics.dispose();

        return resizedImage;
    }

    public static void main(String[] pArgs)
    {
        if (pArgs.length < 4)
        {
            System.err.println("Usage: ScaleImage <url> <width> <height> <output file>");
            System.exit(1);
        }

        try
        {
            BufferedImage scaledImage = scale(ImageIO.read(new URI(pArgs[0]).toURL()), Integer.parseInt(pArgs[1]), Integer.parseInt(pArgs[2]));
            ImageIO.write(scaledImage, pArgs[3].replaceAll(".*\\.(.*)", "$1"), new File(pArgs[3]));
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

Let’s step through the code. The method scale creates a new BufferedImage object with the new scaled dimensions. The following rendering hints are then set on the new BufferedImage.

 graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
 graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
 graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

These instructions tell the Image IO layer how to draw objects onto this image. The last step is to write the input image into the new output BufferedImage. This method sets the box size of the image as the desired image size. Once complete, you have an anti-aliased scaled image that can be used as needed.