Java examples for 2D Graphics:BufferedImage Resize
resize bunch of BufferedImage
//package com.java2s; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; public class Main { public static void resize(File[] images, double factorW, double factorH) { BufferedImage original, resized; Graphics2D g;/*from w w w .ja v a 2s. c o m*/ String extension; for (File i : images) { try { original = ImageIO.read(i); resized = new BufferedImage( (int) (original.getWidth() * factorW), (int) (original.getHeight() * factorH), original.getType()); g = resized.createGraphics(); g.drawImage(original, 0, 0, resized.getWidth(), resized.getHeight(), null); extension = i.getPath().substring( i.getPath().lastIndexOf(".") + 1); ImageIO.write(resized, extension, i); } catch (IOException e) { } } } }