{{error}}
{{(quickSearchResults.length>10)?'10+':(quickSearchResults.length)}} {{(quickSearchResults.length==1)?'result':'results'}}
{{result.title}} {{result.timeStamp | mysql2ymd }}
I am sorry, no such article was written yet.
ImageResize.java (1134 bytes)
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ImageResize {
	static int MAX_SIZE = 150;

	public static void main(String[] args) throws IOException {
		processFile(new File("C:\\Users\\DragosMateiS\\Desktop\\products"));
	}

	private static void processFile(File file) throws IOException {
		if (file.isDirectory()) {
			for (File child : file.listFiles())
				if (child.getName().charAt(0) != '.')
					processFile(child);
		} else if (file.isFile()) {
			BufferedImage image=ImageIO.read(file);
			if (image == null)
				return;
			int width=image.getWidth();
			int height=image.getHeight();
			if(width>height){
				height=MAX_SIZE*height/width;
				width=MAX_SIZE;
			}else{
				width=MAX_SIZE*width/height;
				height=MAX_SIZE;
			}
			BufferedImage resized = new BufferedImage(width, height, image
					.getType());
			Graphics2D g = resized.createGraphics();
			g.drawImage(image, 0, 0, width, height, null);
			g.dispose();
			ImageIO.write(resized, "JPG", file);
		}
	}
}