31

I took some photos and made a huge PDF of them on Omnigraffle (OSX).

Now I need to email that PDF, but since every photo is 5MB, the file is huge. I don't need the high-res photos when I email it though.

So what program will take my PDF, resize all the images to low resolution and save it?

5 Answers 5

36

Open the PDF in Preview, Select File » Save as…, and select the Quartz Filter named Reduce File Size.

enter image description here


Use ColorSync Utility to fine-tune the filter. Duplicate Reduce File Size and change settings afterwards.

I suggest you first try clearing all values from the Image Sampling block, except Resolution, which should be around 150-300 DPI, depending on how much you want to save.

enter image description here

2
  • Where do you find the ColorSync Utility?
    – Karlo
    Jan 31, 2017 at 16:31
  • 1
    @Karlo Utilities folder.
    – Daniel Beck
    Jan 31, 2017 at 17:03
27

Inspired from Max Glenister & Milan Kupcevic, Thanks to Burgi, explanation of the example script : It reduce PDF size from Massive to Small using ebook filter

brew install ghostscript # aptitude work too if you do not have brew

compresspdf() {
    echo 'Usage: compresspdf [input file] [output file] [screen|ebook|printer|prepress]'
    gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/${3:-"screen"} -dCompatibilityLevel=1.4 -sOutputFile="$2" "$1"
}

compresspdf "Massive.pdf" "Small.pdf" ebook

Gs Options:

-dPDFSETTINGS=/screen   (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook    (low quality, 150 dpi images)
-dPDFSETTINGS=/printer  (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default  (almost identical to /screen)
6
  • Can you clarify what your script actually does?
    – Burgi
    Jun 8, 2017 at 15:06
  • It reduce PDF size from Massive to Small using ebook filter :
    – Mickaël
    Jun 9, 2017 at 12:18
  • Can you include that information in your answer? Please see How to Answer and take our tour.
    – Burgi
    Jun 9, 2017 at 13:16
  • I prefer self explainable scripts, but since you don't think it's enough, what you ask for has been done.
    – Mickaël
    Jun 11, 2017 at 9:10
  • 1
    Here a bit (and best) explain it... Dec 30, 2018 at 18:53
1

I don't know of a program that will do what you want, but an alternative to produce the same end result would be to compress the images with a graphics program first, and then put them into a document and convert it to PDF.

1

Based on @Mickaël's answer, if you don't want to install gs to your machine with all of its dependencies, you can also convert the PDF files within a docker container:

docker run --rm -v $(pwd):/app -w /app minidocks/ghostscript -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -sOutputFile="/app/compressed.pdf" /app/source.pdf
1
  • 1
    This worked wonderfully for me, but two notes: 1) if you're on macOS it should be -v "$PWD":/app, and 2) make sure you run this in the directory that the source PDF file is in. Great little script, bookmarking this! Feb 26, 2022 at 20:50
0

Thank you @Mickaël, for your awesome solution,

I've created a minor improvement to control the splitting page -> the default action, and some examples for the tool - https://github.com/Elia-Sh/toolsAndUtils/blob/master/pdfSplit.sh

save the file -

#!/bin/bash

# inspired by: 
#   https://superuser.com/questions/293856/reducing-pdf-file-size
#   https://www.ghostscript.com/doc/current/Use.htm#File_output

usage() {
    cat<<EOF
Usage:
    ${0} <input file> <output file> [screen|ebook|printer|prepress]

EOF
}
# Examples:
# Note: Ghostscript must be installed on your system
# Note that <n> represents the number of pages in the original document;

#     * Only split file to pages; no range available -
#         \$ ${0} someFile.pdf
#       will create the following single page files:
#         someFile_page_0001.pdf, someFile_page_0002.pdf someFile_page_0003.pdf, someFile_page_000<n>.pdf

#     * Split page to custom output file name -
#         \$ ${0} someFile.pdf newFileName_pageNumer_%2d.pdf
#       will create the following single page files:
#         newFileName_pageNumer_01.pdf, newFileName_pageNumer_02.pdf, newFileName_pageNumer_03.pdf, newFileName_pageNumer_0<n>.pdf

#     * Only reduce quality of pdf file !without! splitting -
#         \$ ${0} someFile.pdf newFileName.pdf ebook
#       will create the following single file: newFileName.pdf with reduced quality

#     * Reduce quality !and! split pdf to single pages -
#         \$ ${0} someFile.pdf newFileName_%2d.pdf ebook
#       will create the following single page files, with lower qualuty
#         newFileName_page_01.pdf, newFileName_page_02.pdf, newFileName_page_03.pdf, newFileName_page_0<n>.pdf

### main ###
DEFAULT_QUALITY="printer"
numberOfArguments=$#

case $numberOfArguments in
    1)
        # only split the file
        fileNameInput=$1
        fileNameOutput="${fileNameInput}_page_%04d.pdf"
        pdfSettings=$DEFAULT_QUALITY
        ;;
    2)
        # user supplied input and output files
        fileNameInput=$1
        fileNameOutput=$2
        pdfSettings=$DEFAULT_QUALITY
        ;;
    3)
        # user supplied input and output files
        fileNameInput=$1
        fileNameOutput=$2
        pdfSettings=$3
        ;;
    *)
    # incorrect syntax print usage and exit
        echo "Error: Illegal number of parameters."
        usage
        exit 1
    ;;
  esac

if [[ ! -f $fileNameInput ]]; then
    echo "Error: ${fileNameInput} not found!"
    exit 2
fi

if ! which gs > /dev/null 2>&1; then
    echo "Error: Looks like the Ghostscript package is not installed on your system."
    exit 3
fi

cmdToExecute="gs -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH \
    -dPDFSETTINGS=/$pdfSettings -dCompatibilityLevel=1.4 \
    -sOutputFile=$fileNameOutput $fileNameInput"

echo -e "Executing:\n    "$cmdToExecute

$cmdToExecute
# finish script with the return code from gs command
exit $?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .