#!/bin/bash
#                       /usr/local/bin/pdf2png
# https://crystalfaeries.net/posix/bin/pdf2png
# celeste:crystalfaery 2018-01-23 21:20:18+00:00
# Original: http://stackoverflow.com/questions/653380/converting-a-pdf-to-png 2013-04-14 15:39:08+00:00
# By default we're getting a single output .png of the first page of the .pdf
#... not quite what we'd hoped for, i.e. individual .png's of each image inside the .pdf

while [ $# -gt 0 ];
do
    pdf="${1}"
    shift
    echo -n "Converting ${pdf} "	1>&2
    pngfile=`echo "${pdf}" | sed 's/\.\w*$/.png/'`
    echo " to ${pngfile}"		1>&2
    inkscape "${pdf}" -z --export-dpi=600 --export-area-drawing --export-png="${pngfile}"
done

