Creating Website Thumbnails
Hi
Basically I am trying to create thumbnails of websites when passed the
URL. So far I have used this:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
class ScreenCapture {
public static void main(String args[]) throws
AWTException, IOException, InterruptedException {
// capture the whole screen
String[] cmd = { "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
"http://www.facebook.com" };
Runtime.getRuntime().exec(cmd);
Thread.sleep(1000);
BufferedImage screencapture = new Robot().createScreenCapture(
new
Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
// Save as JPEG
File file = new File("screencapture.jpg");
ImageIO.write(screencapture, "jpg", file);
// Save as PNG
// File file = new File("screencapture.png");
// ImageIO.write(screencapture, "png", file);
}
}
This more or less captures a screenshot of firefox with the webpage
open. Currently I have used Thread.sleep(1000) as a delay for the
webpage to load in FireFox before a screenshot is taken. Is there any
way Firefox or IE can callback to the java app when the webpage loads?
P.S I am a Java novice, so be nice :P
Cheers
Lawrence