Memories of childhood

Thursday, June 21st, 2007

Today, I got a scanner and my brother wanted to scan some of our childhood photographs. So, we put four photos in each of corner of the scanner and scanned them.

After all, we had huge images, which should be split into four separate images. That was a pretty straightforward boring process. So, finally, I thought of writing a small piece code to split the images. and that�s written in JAVA :O. Code is not written for posting, so looks like poorly written code, but anyway it does the job.

import java.awt.image.*;
import javax.imageio.*;
import java.io.*;

public class ImageSpliter {
	public static void main(String args[]) {
		try {
			File file = new File(args[0]);
			int x = Integer.parseInt(args[1]);
			BufferedImage input = ImageIO.read(file);
			BufferedImage output = input.getSubimage(0,
							0,700,1000);
			File fo = new File(”C:/photos/”+x+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(0,
					1400,700,input.getHeight()-1400);
			fo = new File(”C:/photos/”+(x+1)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(1100,
					0,input.getWidth()-1100,1000);
			fo = new File(”C:/photos/”+(x+2)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);

			output = input.getSubimage(1100,
				1400,input.getWidth()-1100,input.getHeight()-1400);
			fo = new File(”C:/photos/”+(x+3)+”.jpg”);
			ImageIO.write(output,”JPG”,fo);
		} catch(Exception e) {
			System.out.println(e.toString());
		}
	}
}

Netbeans 5.5 with Beryl

Saturday, February 10th, 2007

A solution emerged while doing little bit of browsing. Just have to export a variable :

export AWT_TOOLKIT=MToolkit