Skip to content

Instantly share code, notes, and snippets.

@BookGin
Created March 9, 2017 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BookGin/69bdf4366e0c1b7ca6df3555c62f1f7c to your computer and use it in GitHub Desktop.
Save BookGin/69bdf4366e0c1b7ca6df3555c62f1f7c to your computer and use it in GitHub Desktop.
pdf2img
#!/usr/bin/env bash
if [ $# != 1 ]; then
echo "Usage: $0 [filename]"
exit 1
fi
lastdir=`pwd`
tmpdir=`mktemp -d --suffix=-pdf2img`
echo "temp dir: $tmpdir"
convert -density 144 $1 "$tmpdir/%d.png"
total_files=`ls -1 $tmpdir | wc -l`
cd $tmpdir
inputfiles=""
for i in `seq 0 $[total_files-1]`; do
inputfiles+="$i.png "
done
convert $inputfiles out.pdf
mv out.pdf $lastdir/pdfimg-$1
echo "output: $lastdir/pdfimg-$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment