Summary: | loosing quality of images with ps2pdf | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | Werner Meyer <mey.wer> |
Component: | Documentation | Assignee: | Default assignee <ghostpdl-bugs> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | CC: | htl10 |
Priority: | P4 | ||
Version: | 7.21 | ||
Hardware: | PC | ||
OS: | Linux | ||
Customer: | Word Size: | --- | |
Attachments: |
ps-file
quality-loss (ps2pdf without options) good quality but differences? large file, ps2pdf with many options |
Description
Werner Meyer
2009-12-14 16:34:57 UTC
Please try ps2pdf -dDownsampleColorImages#false -dDownsampleGrayImages#false -dDownsampleMonoImages#false FILE.PS FILE.PDF All these parameters are documented in doc/ps2pdf.htm in your Ghostscript package. According to the documentation, Downsample*Images are false by default... In any case, I use -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \ -dPDFsettings=/prepress where I want to preserve image quality. You may want to add the Gray equivalent of those two filter options as well. As Alex wrote, all these options are documented in doc/ps2pdf.htm . OK - in /usr/share/doc/packages/ghostscript-library/doc/Ps2pdf.htm there is written something about it (in the man-page unfortunately not). But my english is to bad to understand this all. I tried ps2pdf -dDownsampleColorImages#false -dDownsampleGrayImages#false -dDownsampleMonoImages#false but this was not a solution. Same result as before. The pictures lost much quality (seems to be strongly compressed jpg). (pdf has a fourth of the size of the ps) So I tried ps2pdf -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFsettings=/prepress The pictures are much better, the pdf has three and a half the size of the ps. But I wonder about the fact, that the images aren't identical. They don't loose so much of quality, but they differ a little bit. I don't understand this. Isn't it possible, to leave them absolutely as they are? Try putting all the options in (and have the prepress switch up front) - "#" is the same as "=" : ps2pdf -dPDFsettings=/prepress \ -dDownsampleColorImages#false -dDownsampleGrayImages#false \ -dDownsampleMonoImages#false \ -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \ -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode \ file.ps The difference you see is also likely due to difference in viewer characteristics, not ps2pdf. Presumably you are using gsview/ghostview/gv/ggv for ps and acroread/xpdf/evine/okular/kpdf for pdf's. Also, if the version 7.21 is true, you are using a fairly old version of ghostscript. Feel free to look at Ps2pdf.htm and add more options to experiment. You saw how the options are used in the above command line. If you need any further help, attaching the file you try to process to the bug report would be a good idea. (you can mark it as private if desired). The proposed options seem to take the same effect as the former. 1,2MB ps gets 4,4 MB pdf. I followed the differences in appearence in okular for both - ps and pdf (don't know, what okular uses to show ps). If the pictures really are the same, only otherwise displayed, its OK. I'll make attachements. btw ps2pdf is maybe 8.64 (comes with opensuse11.2) - the man-page sayd 7.21, the doc...htm says 8.64 Created attachment 5780 [details]
ps-file
Created attachment 5781 [details]
quality-loss (ps2pdf without options)
Created attachment 5782 [details]
good quality but differences? large file, ps2pdf with many options
(Correct the version - the reporter is using v8.64, not 7.21) The image processing in the two files are working as by design. The original ps file has 5 figures, 4 small ones run-length-encoded, and 1 big jpeg at 2048x1536, and scaled and shrinked to embed in the document. The difference in file size is entirely due to how the large jpeg is treated, whether to down-sample to match its size on page and/or write it back with a non-lossy compression. Down-sample + DCTDecode gives 224013 bytes and don't-down-sample + FlateDecode gives 4482132 bytes. The man-page contains: "SEE ALSO Ps2pdf.htm in the Ghostscript documentation" and all the switches/behaviors are as documented in Ps2pdf.htm . Only for my interest (I just don't understand it): why is the pdf with non-loss-compressed image larger than the ps-file, from which its generated? It cannot contain mor information than the ps... Thanks for explaining (which not really belongs to a bugzilla...). The original image is a JPEG, the final image is a straight bitmap which is flate (Zip) encoded for compression. JPEG is a more efficient encoding scheme, so its smaller. However because the original JPEG is expanded out to a full resolution image before being written to a PDF file, if we wrote back a JPEG then the result would contain obvious JPEG compression artefacts (applying lossy compression to an image which was the result of decompressing a lossy compression). Just like any other time you read/modify/save a JPEG file. So that's a bad idea, and you should stick with Flate. |