[magick-users] Website screenshots (with script)
Henryk Gerlach
hgerlach at compals.com
Sat Jan 1 05:16:53 PST 2005
Hi List,
i was trying to make screenshots of websites.
In an earlier discussion some proposed
$ convert index.html jpgindex.jpg
but i get the following error:
sh: line 1: -U: command not found
convert: No decode delegate for this image format (/tmp/magicmReryc)
so i wrote a script myself. It fires up mozilla, takes a screeshot etc.
I use Xvnc, because I don't need to see, what the script is doing, but you may
leave VIRTUAL_X empty and set DISPLAY to ":0" (or whatever your display is)
to see, what's happening.
The script is not really that reliable, but it might be a good start. It works
for me on SuSE Linux 9.0.
===============================
#!/bin/sh
# A script to take screenshots of webpages.
#
# Example usage: webthumb.sh << END
# http://www.mozilla.org mozilla.png mozilla_thmb.png
# http://www.imagemagick.org imagemagick.png imagemagick_thmb.png
# http://www.uk.research.att.com/archive/vnc/xvnc.html xvnc.png xvnc_thmb.png
# END
#
# Requires:
# * ImageMagick
# * Mozilla
# * Xvnc (as Virtual X server), you might also fire up X.org for that purpose
#
# Author: Henryk Gerlach (2005-01-01)
# No warranty, use at own risk.
# This script is Public Domain. All the hard work is done third party software
anyway.
#BUGS:
# Mozilla:
# * -geometry does not work with mozilla
# * if mozilla already runs under the userid it might not start up.
# * if mozilla needs to be configured for the userid running it, the script
won't work
BROWSER=mozilla
#The window title of the browser after startup, so we can grab it's window id.
#If all fails, take root to grab the whole desktop
BROWSERID="Mozilla"
#BROWSERID="root"
DISPLAY=":1"
#Use virtual X server
VIRTUAL_X="Xvnc -depth 16 -localhost -geometry 1024x768 $DISPLAY"
#cut of browser decoration for 800x600 resolution
CROP="800x490+0+90"
THUMBSIZE="120x90"
INITTIME=5 #time to wait for the Xserver and the browser to start up
LOADTIME=4 #time to wait for a page to load, take shot after this time
######################################################
#init
if test "$VIRTUAL_X" != ""; then
$VIRTUAL_X &
fi
export DISPLAY
sleep $INITTIME
$BROWSER &
sleep $INITTIME
if test "$BROWSERID" != "root"; then
BROWSERID=`xwininfo -name "$BROWSERID" | grep "Window id" | cut -d " " -f 4`
fi
# loop
while read URL BIG THUMB; do
$BROWSER -remote "openurl($URL)"
sleep $LOADTIME
import -window "$BROWSERID" $BIG
if test "$CROP" != ""; then
mogrify -crop $CROP "$BIG"
fi
convert -size "$THUMBSIZE" "$BIG" -resize "$THUMBSIZE" "$THUMB"
done
#cleanup
#this is ugly
if test "$VIRTUAL_X" != ""; then
killall Xvnc
else
killall $BROWSER
fi
===============================
Happy new year,
Henryk
--
--
www.compals.com
More information about the Magick-users
mailing list