问题描述
我发出以下命令:
gs \
-o downsampled.pdf \
-sDEVICE=pdfwrite \
-dDownsampleColorImages=true \
-dColorImageResolution=180 \
-dColorImageDownsampleThreshold=1.0 \
并出现以下错误:
Subsample filter does not support non-integer downsample factor (1.994360)
Failed to initialise downsample filter, downsampling aborted
(在某些页面上)
和:
Subsample filter does not support non-integer downsample factor (2.000029)
Failed to initialise downsample filter, downsampling aborted
最初,我尝试将采样率下采样到150dpi,这会导致错误的系数为(2.40 ????),表示多个错误,其中不同页面的最后几位数字是不同的.因此,我猜想图像约为150 * 2.4 = 360 dpi.因此,我尝试将采样率降低到180.但是似乎所有图像都略有偏离?
Originally I tried to downsample to 150dpi, which gave the error with factor (2.40????), meaning multiple errors, where the last few digits are different for different pages. So I guessed that images are approximately 150*2.4 = 360 dpi. So I try downsampling to 180. But it seems the images are all slightly off?
- 是否可以指定系数而不是dpi?
- 有没有一种方法可以四舍五入"这个因素?
推荐答案
否,无法指定因子(这是Adobe蒸馏器参数的规范,我们目前仅限于此).您也不能在不修改源代码的情况下指定四舍五入的近似值.
No, there is no way to specify the factor (this is the Adobe specification for distiller params, we are currently limited to those). You cannot specify an approximation for rounding either, without modifying the source code.
您可以使用其他下采样算法.
You can use a different downsampling algorithm.
[稍后]
实际上我只是检查了当前代码,并且您必须使用旧版本的Ghostscript.
In fact I just checked the current code, and you must be using an old version of Ghostscript.
当前默认的下采样滤波器是Bicubic滤波器,如果您确实强加了Subsample滤波器,则代码将检查所请求的下采样因子是否为整数.
The current default downsampling filter is the Bicubic filter, and if you do force the Subsample filter, then the code checks to see if the downsample factor requested is an integer.
如果因子不是整数,但在整数的0.1范围内,则将因子强制为最接近的整数.
If the factor is not an integer but is within 0.1 of an integer then it forces factor to the nearest integer.
如果它的整数因子在0.1之外,则会中止子样本过滤器并切换为Bicubic.
If its outside 0.1 of an integer factor then it aborts the subsample filter and switches to Bicubic.
我建议升级.
[稍后编辑]
因此,避免使用伪造的ColorDownsampleOption,实际上问题根本不是彩色图像,单色图像,或者更确切地说,不是图像蒙版.
So avoiding the bogus ColorDownsampleOption, the problem is actually not colour images at all, its monochrome images, or more precisely in your case, imagemasks.
我设置了以下命令行:
gs
-sDEVICE=pdfwrite \
-sOutputFile=pdfwrite.pdf \
-dDownsampleColorImages=true \
-dDownsampleGrayImages=true \
-dDownsampleMonoImages=true \
-dColorImageDownsampleThreshold=1 \
-dGrayImageDownsampleThreshold=1 \
-dMonoImageDownsampleThreshold=1 \
-dColorImageDownsampleType=/Bicubic \
-dGrayImageDownsampleType=/Bicubic \
-dMonoImageDownsampleType=/Bicubic \
-dColorImageResolution=72 \
-dGrayImageResolution=72 \
-dMonoImageResolution=100 "gs sample.pdf"
这会产生一条错误消息,即唯一可用于单色图像的滤镜是子样本",然后是您引用的关于不精确因素的错误消息.
And that produces an error message that the only filter available for monochrome images is Subsample, followed by the error messages you quote about the imprecise factor.
我想这基本上表明了我的观点,即示例文件对于调查问题非常重要.
I guess basically this makes my point that an example file is pretty much vital in order to investigate problems.
因此,这里存在一个问题,我将对其进行研究,显然对于单色图像,应将其钳位到最接近的整数分辨率,因为不可能使用其他滤镜.但是,灰度和彩色图像确实可以正常工作.
So there is a problem there, and I will look into it, obviously for monochrome images it should be clamped to the nearest integer resolution, since no other filter is possible. However, Gray and Colour images do work as expected.
正如我在较早的评论中所建议的那样,报告错误可能会更早地到达这一点.我仍然建议您这样做,这样就不会被忽略.
Reporting a bug, as I suggested in an early comment would probably have got to this point much sooner. I'd still suggest you do that, so that this is not overlooked.
您可能会想注意,对我而言,当我不对单色图像进行降采样但对其他图像进行降采样时,生成的文件为原始文件785KB是2.5MB.
You may be interested to note that, for me, the resulting file when I don't downsample monochrome images, but do downsample the others, as per the command line above, is 785KB the original being 2.5MB.
这篇关于pdf图像的ghostscript下采样,下采样因子误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!