]> gitweb.fluxo.info Git - httruta.git/commitdiff
Support for saving URL as a PNG using wkhtmltoimage
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 25 Mar 2017 23:43:16 +0000 (20:43 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 25 Mar 2017 23:43:16 +0000 (20:43 -0300)
config.default
lib/httracker/functions

index f504087674687d0bc940e3ea37740a18bdb8d657..258c8c8959340bfd032ce27953ca538e8f7eaa23 100644 (file)
@@ -12,4 +12,5 @@ EXT_DEPTH="0"
 SCUTTLE_BASE="/var/sites/links"
 WEBKIT2PNG="0"
 WKHTMLTOPDF="1"
+WKHTMLTOIMAGE="1"
 WEBKIT2PDF="0"
index 36286d5a4a71b72fd5c2ec5ca7d680852f24c940..7d3b4b59d8a35ee5d9f022c6c2ed0bc5af5ef0a0 100644 (file)
@@ -66,19 +66,16 @@ function httracker_get {
     rm -rf $TARGET
   fi
 
-  # Get a screenshot
-  # https://github.com/paulhammond/webkit2png/
-  # https://github.com/adamn/python-webkit2png
-  # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png
-  if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then
-    xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url"
-  fi
-
-  # Build a PDF
+  # Save as PDF
   if [ "$WKHTMLTOPDF" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltopdf &> /dev/null; then
     xvfb-run -a wkhtmltopdf "$url" $TARGET/screenshot.pdf
   fi
 
+  # Save as PNG
+  if [ "$WKHTMLTOIMAGE" == "1" ] && which xvfb-run &> /dev/null && which wkhtmltoimage &> /dev/null; then
+    xvfb-run -a wkhtmltoimage "$url" $TARGET/screenshot.png
+  fi
+
   # See https://www.insecure.ws/linux/serverless_screenshot.html
   #     http://gfdsa.gfdsa.org/2012/08/15/making-web-pages-screenshots-with-webkit2png-flash-included/
   if [ ! -d "$TARGET/screenshot.pdf" ]; then
@@ -87,6 +84,16 @@ function httracker_get {
     fi
   fi
 
+  # Get a screenshot
+  # https://github.com/paulhammond/webkit2png/
+  # https://github.com/adamn/python-webkit2png
+  # https://snippets.aktagon.com/snippets/504-how-to-generate-screenshots-on-debian-linux-with-python-webkit2png
+  if [ ! -d "$TARGET/screenshot.png" ]; then
+    if [ "$WEBKIT2PNG" == "1" ] && which xvfb-run &> /dev/null; then
+      xvfb-run -a $DIRNAME/webkit2png/webkit2png/webkit2png.py -o $TARGET/screenshot.png "$url"
+    fi
+  fi
+
   # Fix permissions again
   if [ "`whoami`" != "$USER" ] && [ "`whoami`" == "root" ]; then
     echo "Fixing $TARGET permissions..."