• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

i don't know how to do the iterator directory for image resize, all i can do is 1 by 1. i need helps...


Brantley    0

import javax.imageio.ImageIO;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class test {

    public static void main(String... args) throws IOException {

        File input = new File("C:\\Users\\Brantley\\Desktop\\pt\\latest\\48.jpg");
        BufferedImage image = ImageIO.read(input);

        BufferedImage resized = resize(image, 28, 28);

        File output = new File("C:\\Users\\Brantley\\Desktop\\pt\\jpg\\48.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);
        return resized;


Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.