2

Linux 中使用 Ghostscript 压缩 pdf 文件

 1 year ago
source link: https://blog.kelu.org/tech/2022/07/25/linux-command-for-pdf-compress.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux 中使用 Ghostscript 压缩 pdf 文件

2022-07-25     tech linux pdf
linux.jpg

大多数 Linux 发行版已经包含了 Ghostscript 的开源版本。如果没有的话如下安装:

apt install ghostscript

假如我要压缩 编程珠玑.pdf 这个文件:

/usr/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -dColorImageResolution=150 -sOutputFile=编程珠玑_compressed.pdf 编程珠玑.pdf

关于压缩质量,我们只要修改 dPDFSETTINGS 这个参数即可:

dPDFSETTINGS 描述
/prepress(默认) 高质量 (300 dpi) 但文件较大
/ebook 中质量 (150 dpi) 适中的文件大小
/screen 低质量 (72 dpi) 但输出文件较小

ebook 是在文件大小和清晰度上比较合适的,我就用了它。压缩了40%左右。

image-20220725102425521

其他更多参数参考 Ghostscript 在线文档


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK