减少PDF文件大小


21

我拍了一些照片,并在Omnigraffle(OSX)上制作了一张巨大的PDF。

现在,我需要通过电子邮件发送PDF,但是由于每张照片均为5MB,因此文件很大。通过电子邮件发送时,我不需要高分辨率照片。

那么,什么程序可以获取我的PDF,将所有图像调整为低分辨率并保存呢?

Answers:


24

在“预览”中打开PDF,选择“ 文件”»“另存为...”,然后选择名为“ 减小文件大小”Quartz过滤器

在此处输入图片说明


使用ColorSync Utility对滤镜进行微调。复制缩小文件大小,然后更改设置。

我建议您首先尝试清除“ 图像采样”块中的所有值,但“ 分辨率”除外,该值应在150-300 DPI左右,具体取决于您要保存多少。

在此处输入图片说明


在哪里可以找到ColorSync Utility?
卡洛

1
@Karlo Utilities文件夹。
丹尼尔·贝克

11

灵感来自Max GlenisterMilan Kupcevic,感谢Burgi对示例脚本的解释:使用电子书过滤器将PDF大小从Massive减小为Small

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选项:

-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)

您能否阐明脚本的实际作用?
Burgi

它使用电子书过滤器减少PDF文件大小从大规模到小:
的Mickaël

您可以在回答中包含这些信息吗?请参阅“ 如何回答”并开始我们的游览
Burgi

我更喜欢可自我解释的脚本,但是由于您认为这还不够,所以您要求的内容已经完成。
的Mickaël

1
在这里(最好)解释一下……
Abdel Karim Mateos Sanchez

1

我不知道会执行您想要的程序的程序,但是产生相同最终结果的另一种方法是先使用图形程序压缩图像,然后将其放入文档中并将其转换为PDF。


0

谢谢@Mickaël的出色解决方案,

我已经做了一个较小的改进以控制拆分页面->默认操作,以及该工具的一些示例-https: //github.com/Elia-Sh/toolsAndUtils/blob/master/pdfSplit.sh

保存文件-

#!/bin/bash

# inspired by: 
#   /superuser/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 $?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.