-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGhostscript_PDF_Compression.sh
More file actions
47 lines (33 loc) · 1.93 KB
/
Ghostscript_PDF_Compression.sh
File metadata and controls
47 lines (33 loc) · 1.93 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
if chemin=$(zenity --file-selection --file-filter="*.pdf" --title="Choose a PDF file to compress")
then
if mode=$(zenity --entry --title="Compression Mode" --text="Please choose a compression mode" --entry-text="Default" "Screen (72dpi)" "Ebook (150dpi)" "Prepress (300dpi)" "Printer (300dpi)" )
then
filename_base=$(basename -- "$chemin") #new file name creation
filename="${filename_base%.*}"
path=$(dirname -- "$chemin")
slash="/"
suffix="_compressed.pdf"
new_path=$path$slash$filename$suffix
if [ "$mode" = "Default" ] #condiion to set the compression mode
then
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new_path" "$chemin" | zenity --progress --pulsate --auto-close
fi
if [ "$mode" = "Screen (72dpi)" ]
then
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new_path" "$chemin" | zenity --progress --pulsate --auto-close
fi
if [ "$mode" = "Ebook (150dpi)" ]
then
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new_path" "$chemin" | zenity --progress --pulsate --auto-close
fi
if [ "$mode" = "Prepress (300dpi)" ]
then
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new_path" "$chemin" | zenity --progress --pulsate --auto-close
fi
if [ "$mode" = "Printer (300dpi)" ]
then
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new_path" "$chemin" | zenity --progress --pulsate --auto-close
fi
fi
fi