Here you can find the source of getSizedImage(final URL url, final Dimension size)
public static BufferedImage getSizedImage(final URL url, final Dimension size) throws IOException
//package com.java2s; //License from project: Apache License import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; public class Main { public static BufferedImage getSizedImage(final URL url, final Dimension size) throws IOException { final BufferedImage image = ImageIO.read(url); final BufferedImage bufferedImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB); final Graphics2D g = bufferedImage.createGraphics(); g.drawImage(image, 0, 0, size.width, size.height, null); g.dispose();// ww w . j a v a 2s . c om return bufferedImage; } }