public static void main(String[] args) throws IOException{
Image img = Toolkit.getDefaultToolkit().getImage("C:\\google.jpg");
BufferedImage bi_scale = toBufferedImage(img);
ImageIO.write(bi_scale, "jpg",new File("C:\\2.jpg"));
}
public static BufferedImage toBufferedImage(Image image) {
if (image instanceof BufferedImage) {
return (BufferedImage)image;
}
// This code ensures that all the pixels in the image are loaded
image = new ImageIcon(image).getImage();
// Determine if the image has transparent pixels; for this method's
// implementation, see e661 Determining If an Image Has Transparent Pixels
//boolean hasAlpha = hasAlpha(image);
// Create a buffered image with a format that's compatible with the screen
BufferedImage bimage = null;