summaryrefslogtreecommitdiff
path: root/pdf2png.sh
diff options
context:
space:
mode:
authorJake VanderVaate <jake.vandervaate@protonmail.com>2021-11-24 14:44:06 -0600
committerJake VanderVaate <jake.vandervaate@protonmail.com>2021-11-24 14:44:06 -0600
commitd472fa0b8850acbb7f55cbb2ed570d2aa81cc334 (patch)
treefa6dfdc19c1cc52ad3db1c259daa06bb1964e807 /pdf2png.sh
parenta7a33e85b36e9465481d4b5ec08bc01bd434820f (diff)
added article template, updated resume and pdf2png
Diffstat (limited to 'pdf2png.sh')
-rwxr-xr-xpdf2png.sh28
1 files changed, 23 insertions, 5 deletions
diff --git a/pdf2png.sh b/pdf2png.sh
index 37c30b8..5628bdb 100755
--- a/pdf2png.sh
+++ b/pdf2png.sh
@@ -1,13 +1,31 @@
#!/bin/sh
#strip the file name off the input PDF
-file="$(ls ""$1"" | sed 's|\.pdf||g')"
+input_pdf="$1"
+file_name="$(find """$1""" | sed 's|\.pdf||g')"
+first_page="$2"
+last_page="$3"
+if [ "$2" = "" ]
+then
+ first_page="1"
+else
+ :
+fi
+
+if [ "$3" = "" ]
+then
+ last_page="$first_page"
+else
+ :
+fi
#convert the PDF to a 600px wide PNG image
-pdftoppm -singlefile -png -scale-to-x 696 -scale-to-y -1 "$1" "$file"
+pdftoppm -f "$first_page" -l "$last_page" -png -scale-to-x 696 -scale-to-y -1 "$input_pdf" "$file_name"
#add a 2x2px border to the image.png file
-convert "$file".png -bordercolor black -border 2x2 "$file".png
+for file in *.png; do
+ convert "$file" -bordercolor black -border 2x2 "$file"
-#compress the image
-optipng "$file".png
+ #compress the image
+ optipng "$file";
+done