bash script to reduce pdf-file(s)
reducepdf.sh <pdf-file to reduce | directory containing pdf-files to reduce>
[options]
All parameters (options) are optional. In the most cases, the default settings are enough.
-
-r to set resolution of page images.
Default resolution is 72. Values in the interval 30..300 are allowable.
Setthings of resolution affect inversally on an output file's size and quality. The same way settings of quality does (bellow).
-
-q <jpeg quality, %> takes values from 1 up to 100.
Default value is 85.
-
-s to set the maximum file size.
The script will process all the files whose size exceeds the maximum size.
The default value is 3000000 bytes (files of 3000000 bytes in size and less will not be processed by default).
-
-m : to choose a utility to compose a pdf-file:
1 - this method uses pdftocairo+img2pdf and requires these packages (pdftocairo and img2pdf) to exist (be installed) on your system
2 - this method uses pdftocairo+convert(ImageMagick) and requires these packages (pdftocairo and ImageMagick) to exist (be installed) on your system
3 - this method uses ghostscript (gs) and requires this package on your system
The default method is 3 (ghostscript).
Depending on what method you use (see description for option "-m" above), you have to have installed either pdftocairo + img2pdf
, or pdftocaito+ImageMagick
, or ghostscript
(gs
) package. By default, ghostscript
is required.
Thanks to:
- The ImageMagick Development Team. ImageMagick
- Ghostscript by Artifex Software, Inc
- The pdftocairo software and documentation, copyrighted by Glyph & Cog, LLC and The Poppler Developers, authors
- img2pdf by Johannes 'josch' Schauer (on PyPI, GitHUB ).