Bug 702531 - Output Page quality image (differently sized background, foreground and mask)
Summary: Output Page quality image (differently sized background, foreground and mask)
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 9.52
Hardware: PC Windows 7
: P4 normal
Assignee: Default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-01 19:40 UTC by alex.farlie
Modified: 2020-09-05 17:29 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Simplified sample file: a6.pdf (75.82 KB, application/pdf)
2020-07-03 05:29 UTC, Peter Cherepanov
Details
a6.jpg (523.10 KB, image/jpeg)
2020-09-05 17:29 UTC, Ray Johnston
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alex.farlie 2020-07-01 19:40:55 UTC
Logging this here from an issue raised in the Wikimedia Phabricator system concerning the rendering of a page scan stored in PDF:-

https://phabricator.wikimedia.org/T256848#6272386

As suggested in the Phabricator ticket, the concerns is that the output from Ghostscript is missing portions of the original, or generating undesirable artefacts.


The same PDF when viewed in the PDF viewer in Firefox Nightly showed no artefacts, So I am wondering if they are using a slightly different decoding approach or are scaling differently sized layers in a different way that generates a subjectively better image.
Comment 1 Peter Cherepanov 2020-07-03 05:29:27 UTC
Created attachment 19410 [details]
Simplified sample file: a6.pdf

This is a simplified page 9 of the sample file.
A high quality, 150 dpi, anti-aliased image can be produced by Ghostscript with the following command line:

~/ghostpdl/debugbin/gs -r600 -sDEVICE=tiffscaled24 -dDownScaleFactor=4 -o hifi.tiff  a6.pdf 

Ghostscript has no downscaling options for other devices, but TIFF can be converted to other raster formats using "convert".
Comment 2 Ray Johnston 2020-09-05 17:27:06 UTC
Since Peter's suggestion produces a high quality result, closing this bug
as FIXED, assuming that the Phabricator users can use this approach.

I will mention that 'convert' (part of ImageMagick) can scale as well as
convert formats, but since this requires creation of an intermediate file as
well, it uses more disk space for the intermediate file than the approach
Peter suggests.

I also suggest that Artifex's other Open Source product, Mupdf, can be used
to produce a high quality document in JPEG format in a single step:

    mutool draw -r150 -o a6.jpg a6.pdf

The mupdf engine (mutool is part of the Mupdf package), anti-aliases internally
by default so the results are similar to using -dDownScalFactor with
Ghostscript.
Comment 3 Ray Johnston 2020-09-05 17:29:54 UTC
Created attachment 19766 [details]
a6.jpg

Output from:
   mutool draw -r150 -o a6.jpg a6.pdf