import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class ResizeImageExample {
public static void main(String... args) throws IOException {
File input = new File("/Users/Brantley/Desktop/pt/latest/2.jpg");
BufferedImage image = ImageIO.read(input);
BufferedImage resized = resize(image, 28, 28);
File output = new File("/Users/Brantley/Desktop/pt/jpg/2.jpg");
ImageIO.write(resized, "png", output);
}
private static BufferedImage resize(BufferedImage img, int height, int width) {
Image tmp = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage resized = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = resized.createGraphics();
g2d.drawImage(tmp, 0, 0, null);
g2d.dispose();
return resized;
}
What I have tried:
i got 200 photo to change size , but what i can do is 1 by 1... any 1 can help me solve iterate directory problem