การลดขนาดไฟล์ PDF


21

ฉันถ่ายรูปและทำ PDF ขนาดใหญ่บน Omnigraffle (OSX)

ตอนนี้ฉันจำเป็นต้องส่งอีเมล PDF นั้น แต่เนื่องจากทุกภาพมีขนาด 5MB ไฟล์จึงมีขนาดใหญ่มาก ฉันไม่ต้องการรูปภาพความละเอียดสูงเมื่อฉันส่งอีเมลถึง

ดังนั้นโปรแกรมใดที่จะใช้ PDF ของฉันปรับขนาดภาพทั้งหมดให้มีความละเอียดต่ำและบันทึก

คำตอบ:


24

เปิด PDF ในตัวอย่างเลือกไฟล์»บันทึกเป็น ...และเลือกกรองควอตซ์ชื่อลดขนาดไฟล์

ป้อนคำอธิบายรูปภาพที่นี่


ใช้ColorSync Utilityเพื่อปรับแต่งตัวกรองอย่างละเอียด ทำซ้ำลดขนาดไฟล์และเปลี่ยนการตั้งค่าในภายหลัง

ฉันขอแนะนำให้คุณลองล้างค่าทั้งหมดจากบล็อกการสุ่มตัวอย่างรูปภาพยกเว้นความละเอียดซึ่งควรมีประมาณ 150-300 DPI ขึ้นอยู่กับจำนวนที่คุณต้องการบันทึก

ป้อนคำอธิบายรูปภาพที่นี่


คุณพบ ColorSync Utility ได้ที่ไหน
Karlo

1
@Karlo Utilities โฟลเดอร์
Daniel Beck

11

แรงบันดาลใจจากMax Glenister & Milan Kupcevicต้องขอบคุณ Burgi คำอธิบายของสคริปต์ตัวอย่าง: มันลดขนาด PDF จาก Massive ถึง Small โดยใช้ตัวกรอง ebook

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 จาก Massive ถึง Small โดยใช้ตัวกรอง ebook:
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 $?
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.