Resize.sh: Difference between revisions
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
This is a version of a script called <code>resample.sh</code> written by [http://osp.kitchen OSP]. | This is a version of a script called <code>resample.sh</code> written by [http://osp.kitchen OSP]. | ||
=== | ===A nice bash script published by OSP=== | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Latest revision as of 13:13, 19 February 2025
This is a bash script based on Ghostscript that can be used to compress/resize a PDF.
This is a version of a script called resample.sh written by OSP.
A nice bash script published by OSP
#! /bin/bash
pdffile=$1;
dpi=$2
gs \
-o "${pdffile%.pdf}-resized.pdf" \
-sDEVICE=pdfwrite \
-dDownsampleColorImages=true \
-dDownsampleGrayImages=true \
-dDownsampleMonoImages=true \
-dColorImageResolution=$dpi \
-dGrayImageResolution=$dpi \
-dMonoImageResolution=$dpi \
-dColorImageDownsampleThreshold=1.0 \
-dGrayImageDownsampleThreshold=1.0 \
-dMonoImageDownsampleThreshold=1.0 \
"${pdffile}"
How to use it?
Save the code above to a file called resize.sh.
The script requires two arguments:
$ ./resize.sh <file.pdf> <resolution in DPI>
For example:
$ ./resize.sh myfile.pdf 300
The output will be something like:
myfile-resized.pdf