Skip to content

Instantly share code, notes, and snippets.

@eduherraiz
Created December 16, 2013 16:10
Show Gist options
  • Save eduherraiz/7989573 to your computer and use it in GitHub Desktop.
Save eduherraiz/7989573 to your computer and use it in GitHub Desktop.
Bash script to get web screenshots using phantomjs
#!/bin/bash
URLS_FILE="/var/www/eduherraiz.com/www/snapshots/urls.txt"
IMGS_DIR="/var/www/eduherraiz.com/www/snapshots/imgs"
for URL in `cat $URLS_FILE`
do
FILE=`echo ${URL//[\/]/}`
#echo $FILE
# Create de screenshot with phantomjs
phantomjs --ignore-ssl-errors=yes --cookies-file=tempcookies \
/usr/local/phantomjs/rasterize.js \
http://$URL \
$IMGS_DIR/original/$FILE.png
convert "$IMGS_DIR/original/$FILE.png" -resize 950 "$IMGS_DIR/resized/$FILE.png"
convert "$IMGS_DIR/resized/$FILE.png" -crop 950x700+0+0 "$IMGS_DIR/croped/$FILE.png"
convert "$IMGS_DIR/croped/$FILE.png" -resize 182 "$IMGS_DIR/thumb/$FILE.png"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment