Taking Screenshots of a Website in Linux

Written by James McDonald

October 21, 2011

They said “James we need someone to check a website and make sure everything is OK over the weekend”. Hmm OK… I’d rather not be tied to a laptop or hang around home so why not send an email with a screenshot to my Android HTC Desire.

Search, search, search:

And then I discovered CutyCapt an app that uses the Webkit QT Rendering Engine to take a screenshot.

I followed the download and install instructions and with Fedora 15 it was easy to compile.

Here is my solution to:

  • Check a website is up firstly. Send error email if it isn’t
  • Take a screen shot in jpeg format
  • Email it to a list of people using mutt connected through a gmail account

CutyCapt running from command line script
Just discovered that this will not work with a cron job. See below for one that does



cd $THIS_DIR || exit

echo removing old jpegs
rm *.jpeg > /dev/null 2>&1

OUTFILE=`date +%Y-%m-%d-%I_%m_%p-my_web_site.jpeg`
MYDATE=`date '+%Y-%m-%d %l:%m %p'`

# here I do a quick check to make sure the site is up using wget
wget --timeout=3 --delete-after --tries=1  > /dev/null 2>&1

if [ "$?" != "0" ] ; then 

    EMAIL="$MYDATE - ERROR: Cannot access my website!"

    echo "$EMAIL" | mutt -s "$EMAIL" me@example.com -c another@example.com -c andanotherCC@example.com


   EMAIL="$MYDATE My Web Site"

   CutyCapt --max-wait=5000 --url=""  --out="$OUTFILE"

   # to get mutt working through your gmail account
   # google "mutt through gmail"
   echo "$EMAIL" | mutt -s "$EMAIL" -a "$OUTFILE"  me@example.com -c another@example.com -c andanotherCC@example.com

# --min-width=1024 --min-height=768 

CutyCapt running under cron script

To work with Cron you need cutycapt to be run using xvfb-run as below


. /etc/profile


echo removing old jpegs 
# (just make sure there are not other jpegs in the dir you are in!)
$RM *-myWebSite.jpeg > /dev/null 2>&1

# check it's up

OUTFILE=`$DATE +%Y-%m-%d-%I_%M_%p-myWebSite.jpeg`
MYDATE=`$DATE '+%Y-%m-%d %l:%M %p'`

$WGET --timeout=3 --delete-after --tries=1  > /dev/null 2>&1

if [ "$?" != "0" ] ; then

        EMAIL="$MYDATE - ERROR: Cannot access My Web Site"

        $ECHO "$EMAIL" | $MUTT -s "$EMAIL" me@example.com -c anothercc@example.com -c andanother@example.com


        EMAIL="$MYDATE My Web Site"

$XVFBRUN --server-args="-screen 0, 1024x768x24" $CUTYCAPT --max-wait=5000 --url=""  --out="$OUTFILE"

        $ECHO "$EMAIL" | $MUTT -s "$EMAIL" me@example.com -a "$OUTFILE" -c anothercc@example.com -c andanother@example.com


CutyCapt has got heaps of options:

 Usage: CutyCapt --url=http://www.example.org/ --out=localfile.png            
  --help                         Print this help page and exit                
  --url=                    The URL to capture (http:...|file:...|...)   
  --out=                   The target file (.png|pdf|ps|svg|jpeg|...)   
  --out-format=               Like extension in --out, overrides heuristic 
  --min-width=              Minimal width for the image (default: 800)   
  --min-height=             Minimal height for the image (default: 600)  
  --max-wait=                Don't wait more than (default: 90000, inf: 0)
  --delay=                   After successful load, wait (default: 0)     
  --user-style-path=       Location of user style sheet file, if any    
  --user-style-string=      User style rules specified as text           
  --header=:        request header; repeatable; some can't be set
  --method=        Specifies the request method (default: get)  
  --body-string=         Unencoded request body (default: none)       
  --body-base64=         Base64-encoded request body (default: none)  
  --app-name=              appName used in User-Agent; default is none  
  --app-version=        appVers used in User-Agent; default is none  
  --user-agent=          Override the User-Agent header Qt would set  
  --javascript=          JavaScript execution (default: on)           
  --java=                Java execution (default: unknown)            
  --plugins=             Plugin execution (default: unknown)          
  --private-browsing=    Private browsing (default: unknown)          
  --auto-load-images=    Automatic image loading (default: on)        
  --js-can-open-windows= Script can open windows? (default: unknown)  
  --js-can-access-clipboard= Script clipboard privs (default: unknown)
  --print-backgrounds=   Backgrounds in PDF/PS output (default: off)  
  --zoom-factor=          Page zoom factor (default: no zooming)       
  --zoom-text-only=      Whether to zoom only the text (default: off) 
  --http-proxy=             Address for HTTP proxy server (default: none)
   is svg,ps,pdf,itext,html,rtree,png,jpeg,mng,tiff,gif,bmp,ppm,xbm,xpm    
 http://cutycapt.sf.net - (c) 2003-2010 Bjoern Hoehrmann - bjoern@hoehrmann.de

Mutt for GMail Config Example

set from = “me@example.com”
set realname = “Mr R J Example”
set imap_user = “me@example.com”
set imap_pass = “YOURGMAILPASSWORD”
set folder = “imaps://imap.gmail.com:993”
set spoolfile = “+INBOX”
set postponed =”+[Gmail]/Drafts”
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set smtp_url = “smtp://me@example.com@smtp.gmail.com:587/”
set smtp_pass = “YOURGMAILPASSWORD”
set move = no
set imap_keepalive = 900
fcc-hook .* ~/.mutt/sent


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...

PC Build

I recently built myself a PC using the SilverStone SG13 Case. I am planning to use it as a Hot Spare. So any client...