blob: ae56a40292cc3a8533bd0dd65eaa452d80cd21f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/sh
input_pdf="$1"
first_page="$2"
last_page="$3"
file_name="$(basename -s .pdf """$1""")"
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 -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
for file in "$file_name"*.png; do
convert "$file" -bordercolor black -border 2x2 "$file"
#compress the image
optipng "$file";
done
|