Memories of childhood

Posted in General, Programming by sandaruwan on 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());
		}
	}
}

2 Responses to “Memories of childhood”

  1. liezmaya Says:

    hi yarr how ru?….thanks for plugin :) awasome

    June 26th, 2007 at 12:29 pm

  2. Abhishek Says:

    I am using your Picasa plugin and it works great!!! Btw, what plugin are you using for highlighting the syntax for the Java code???

    June 27th, 2007 at 3:53 pm

Leave a Reply