pdf2jpg 420 B

12345678910111213141516
  1. #!/bin/bash -eu
  2. # uses graphics magick to extract images from a pdf
  3. if ! which gm &>/dev/null; then
  4. echo "requires gm convert..." && exit 1
  5. elif [ -z "${1:-}" ] || [ ! -f "$1" ]; then
  6. echo "No file supplied..." && exit 1
  7. fi
  8. out="$(dirname "$1")"
  9. if [ -n "${2:-}" ] && [[ ! -f "$2" || -d "$2" ]]; then
  10. out="$2"
  11. mkdir -p "$out" &>/dev/null || true
  12. fi
  13. gm convert -density 300 "$1" +adjoin -quality 100 ${out}/%d.jpg