Bug 697351 - /Subsample filter needs to make non-integer scales integer for monochrome images
Summary: /Subsample filter needs to make non-integer scales integer for monochrome images
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.20
Hardware: Macintosh MacOS X
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-16 09:02 UTC by yiwei.she
Modified: 2016-12-02 11:07 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
monochrome subsample bug test file (2.42 MB, application/pdf)
2016-11-16 09:03 UTC, yiwei.she
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yiwei.she 2016-11-16 09:02:40 UTC
Using the command:
gs \
  -o output.pdf \
  -sDEVICE=pdfwrite \
  -dDownsampleMonoImages=true \
  -dMonoImageDownsampleType=/Bicubic \
  -dMonoImageResolution=200 \
   input.pdf

Gives the following error (on every page):

The only Downsample filter for monochrome images is Subsample, ignoring request. Subsample filter does not support non-integer downsample factor (3.017893) Failed to initialise downsample filter, downsampling aborted. 

According to current documentation at:
http://www.ghostscript.com/doc/9.20/VectorDevices.htm#PDFWRITE,

the Bicubic filter should be supported for monochrome.
Comment 1 yiwei.she 2016-11-16 09:03:24 UTC
Created attachment 13149 [details]
monochrome subsample bug test file
Comment 2 Ken Sharp 2016-11-16 09:11:56 UTC
(In reply to yiwei.she from comment #0)
> According to current documentation at:
> http://www.ghostscript.com/doc/9.20/VectorDevices.htm#PDFWRITE,
> 
> the Bicubic filter should be supported for monochrome.

No, that's not an option, the documentation clearly has a typo which I'll also fix.

Bicubic filtering requires intermediate levels between black and white, so the image would no longer be monochrome, and for imagemasks would no longer be an imagemask. Since the point of downsampling an image is to reduce its size, converting it from 1 bit per pixel to 8 bits per pixel isn't really an excellent plan.

Subsampleing *is* the only option which retains the monochrome nature of monochrome images, but I agree that in this case we should either permit a degree of freedom or, since its one level for all images no matter what the size of the image or its original resolution, clamp to the nearest integer value.
Comment 3 yiwei.she 2016-11-16 11:56:13 UTC
The subsample filter also not rounding when the ration is within .1 of an integer; in the error the ratio is (3.017893).
Comment 4 Ken Sharp 2016-12-02 11:07:23 UTC
commit b880332b899e0e59d17c7e48033e5cc816e5a831 will now force the downsample factor to an integer when the input is a 1 BPP image or imagemask (so we cannot shift to a Bicubic filter) and the downscale factor is not precisely an integer.

Also fixed the mistake in the documenttion.