PDF Size Reduce(compress) using Ghostscript at terminal. Here required 2 things for the process.
shrinkpdf.sh
file- Installed
Ghostscript
in your machine
-
Download the shrinkpdf.sh file from Here
-
Install
Ghostscript
in your machine if not installed
For Mac :
$ sudo brew install ghostscript
For Linux :
RedHat and derivatives :
$ sudo yum install ghostscript
Or on Debian:
$ sudo apt-get install ghostscript
To reduce your pdf file you need to pass 3 parameters
./shrinkpdf.sh [inputfile] [outputfile] [resolution_in_dpi]
- [inputfile] : Actual Filename of the PDF that is to be converted
- [outputfile] : New filename of the converted PDF
- [resolution_in_dpi] : The DPI (resolution) for the output PDF. Output resolution defaults is : 72 . You can use your own choice like 150 dpi , 150 dpi etc.
N.B: Lower DPI is better but the quality will be worse
Step 1 :
Make the shrinkpdf.sh
file executable and give it permissions to execute by bellow command
$ sudo chmod +x shrinkpdf.sh
Now your shrinkpdf.sh
file is executable.
Step 2 :*
Now you can execute the the shrinkpdf.sh
$ sudo ./shrinkpdf.sh sample-pdf.pdf output.pdf 150
It will create a new file name output.pdf
with 150dpi in same directory.
you can check the file size by below command.
$ du -sh *
4.0K README.md
124K output.pdf
460K sample-pdf.pdf
4.0K shrinkpdf.sh