Last active
August 9, 2018 09:56
-
-
Save 4383/4a8f03a2425d0908d0ae073d58a07c56 to your computer and use it in GitHub Desktop.
Bash functions to compress pdf files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Bash functions to compress pdf files | |
## Usage: | |
## $ source compress-pdf.sh | |
## $ compress-pdf-medium | |
function compress-pdf-medium { | |
# Medium level compression | |
# Medium does mean it's the medium quality level | |
gs \ | |
-sDEVICE=pdfwrite \ | |
-dCompatibilityLevel=1.4 \ | |
-dPDFSETTINGS=/ebook \ | |
-dNOPAUSE \ | |
-dBATCH \ | |
-sOutputFile=$2 \ | |
$1 | |
} | |
function compress-pdf-low { | |
# Low level compression | |
# Low does mean it's the lowest quality level | |
gs \ | |
-sDEVICE=pdfwrite \ | |
-dCompatibilityLevel=1.4 \ | |
-dPDFSETTINGS=/screen \ | |
-dNOPAUSE \ | |
-dBATCH \ | |
-sOutputFile=$2 \ | |
$1 | |
} | |
function compress-pdf-high { | |
# High level compression | |
# High does mean it's the highest quality level | |
gs \ | |
-sDEVICE=pdfwrite \ | |
-dCompatibilityLevel=1.4 \ | |
-dPDFSETTINGS=/screen \ | |
-dNOPAUSE \ | |
-dBATCH \ | |
-sOutputFile=$2 \ | |
$1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some bash functions for pdf files compression
Prerequisites
apt-get install ghostscript
Usage
Persistant configuration
You can source automaticaly these functions by adding the following command to your
~/.bashrc
: