如何在PDF文件中对图像进行下采样? [英] How to downsample images within PDF file?
问题描述
需要基于Java的解决方案,或者在最糟糕的情况下,需要Linux的命令行。
Need a Java-based solution or, at the worst, command-line for Linux.
我尝试使用Ghostscript:
I tried to use Ghostscript:
gs -sDEVICE=pdfwrite -dPDFA -dBATCH -dNOPAUSE -dUseCIEColor \
-sProcessColorModel=DeviceCMYK -sPDFACompatibilityPolicy=1 \
-sOutputFile=downgraded.pdf leon_range_my12_w22_brochure.pdf
但我收到了很多错误...
but I got a lot of errors...
推荐答案
以下是如何使用Ghostscript命令行将所有(彩色,灰色和单色)图像下采样到72dpi的示例:
Here's an example of how you can downsample all (color, gray and mono) images to 72dpi with a Ghostscript commandline:
gs \
-o downsampled.pdf \
-sDEVICE=pdfwrite \
-dDownsampleColorImages=true \
-dDownsampleGrayImages=true \
-dDownsampleMonoImages=true \
-dColorImageResolution=72 \
-dGrayImageResolution=72 \
-dMonoImageResolution=72 \
-dColorImageDownsampleThreshold=1.0 \
-dGrayImageDownsampleThreshold=1.0 \
-dMonoImageDownsampleThreshold=1.0 \
input.pdf
更新:
* ImageDownsampleThreshold = 1.0
参数强制执行 all 分辨率高于目标分辨率72 dpi的图像将被下采样。如果未给出此参数(或设置为其他值),将使用默认值: * ImageDownsampleThreshold = 1.5
。此默认值仅对值为108 dpi(或更高)的图像进行下采样,并保持其他图像不变。
Update:
The *ImageDownsampleThreshold=1.0
parameters enforce that all Images with a resolution higher than the target resolution of 72 dpi will be downsampled. If this parameter is not given (or set to a different value), the default values will be used: *ImageDownsampleThreshold=1.5
. This default value will only downsample images with a value of 108 dpi (or higher) and leave the other ones untouched.
这篇关于如何在PDF文件中对图像进行下采样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!