screencapture test

# yum install ImageMagick
# yum install ImageMagick-devel
# yum install ImageMagick-perl

http://www.ishihara.ne.jp/blog/archives/2006/05/imagemagickperl.html

yum grouplist
yum groupinfo "X Window System"
yum upgrade xorg-x11-xfs
yum upgrade xorg-x11
yum upgrade xorg-x11-devel
yum upgrade xorg-x11-libs
yum groupupdate "X Window System"
yum upgrade xorg-x11-libs
yum install xorg-x11-Xvfb
yum install firefox

mkdir /tmp/webshot/
firefox -createprofile "webshot /tmp/webshot/"

echo '#!/bin/bash
#
# chkconfig: - 91 35
# description: Starts and stops XVfb. \
# used to provide virtual frame buffer.

# Source function library.
. /etc/init.d/functions

prog=$"Xvfb"

# Xvfb program
XVFB=/usr/X11R6/bin/Xvfb

start() {
echo -n $"Starting $prog: "
daemon /usr/X11R6/bin/Xvfb :1 -screen 0 1024x1024x24 &
echo
}

stop() {
echo -n $"Shutting down $prog: "
killproc Xvfb
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

exit 0
' > /etc/init.d/xvfb
chmod 755 /etc/init.d/xvfb
chkconfig xvfb on



chkconfig が動かなかった

必要か?

export DISPLAY=:1.0
firefox -display :1 -width 800 -height 1024 -P "webshot" &
firefox -display :1 -remote "openurl(http://www.drk7.jp/)"




#!/usr/bin/perl -w
use Image::Magick;

$ENV{DISPLAY} = ':1.0';
my $url = $ARGV[0] or die 'need url args..';
my $img_fname = 'sample.png';
my $thumb_fname = 'sample_thumb.png';

`firefox -display :1 -remote "openurl($url)"`;
`import -display :1 -window root -silent $img_fname`;

$img=Image::Magick->new;
$img->Read($img_fname);
$img->Crop('768x768+0+90');
$img->Set(quality=>90);
$img->Scale( width=>128, height=>128 );
$img->Write($thumb_fname);


perl test.pl http://www.yahoo.co.jp/



via http://www.drk7.jp/MT/archives/001042.html

↑の補足として http://pink.cc/archives/2006/07/webnail_web.html