Bug 88971 - [PATCH] Add a pdftops -preservecolorspace option to suppress optimization to DeviceRGB color space
Summary: [PATCH] Add a pdftops -preservecolorspace option to suppress optimization to ...
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-04 18:21 UTC by William Bader
Modified: 2015-02-18 18:36 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patches to add -preservecolorspace (4.38 KB, patch)
2015-02-04 18:21 UTC, William Bader
Details | Splinter Review
my print without preservecolorspace option (1.41 MB, image/jpeg)
2015-02-05 15:02 UTC, Benjamin Lefevre
Details
my print without preservecolorspace option (zoom) (1.01 MB, image/jpeg)
2015-02-05 15:04 UTC, Benjamin Lefevre
Details
my print with preservecolorspace option (1.39 MB, image/jpeg)
2015-02-05 15:04 UTC, Benjamin Lefevre
Details
Alternate patch that adds -optimizecolorspace (4.34 KB, patch)
2015-02-05 21:09 UTC, William Bader
Details | Splinter Review
Updated alternate patch to add -optimizecolorspace (4.63 KB, patch)
2015-02-06 00:16 UTC, William Bader
Details | Splinter Review
Updated alternate patch to add -optimizecolorspace with man page (5.86 KB, patch)
2015-02-06 01:16 UTC, William Bader
Details | Splinter Review

Description William Bader 2015-02-04 18:21:08 UTC
Created attachment 113166 [details] [review]
Patches to add -preservecolorspace

pdftops 0.17.2 in August 2011 added an optimization to convert RGB and CMYK bitmaps with equal components in every pixel into Gray bitmaps.
This fixes problems where PDFs with embedded RGB images would not work well when separated into CMYK plates for printing.
There are times when it is better to leave gray images encoded as RGB as RGB.  See for example, the image https://www.dropbox.com/s/yoj6h3o4irnlgun/source.pdf?dl=0
The attached patches add a -preservecolorspace to preserve gray images encoded as RGB as RGB.
Comment 1 Adrian Johnson 2015-02-04 21:55:02 UTC
I would expect that by default pdftops should produce output that always works. Any optimizations that may degrade the output in some cases should be disabled by default and require an option to be enabled. In most cases pdftops is invoked automatically by cups. Users are not able to easily change pdftops options or recognize that when there is a problem with the printing output that the pdftops options require tweaking.
Comment 2 William Bader 2015-02-05 00:58:59 UTC
I am building postscript pages from EPS files. Some of the EPS files are created from third-party PDFs by pdftops.  I made the optimization because one of the sources of PDFs liked to embed gray logos as RGB images, and when the resulting EPS files got on my pages, Adobe pre-press applications flagged the RGB images and did a bad color separation.

I think that the underlying issue is that printing RGB images to a CMYK printer is not a good idea.

The optimization has been in pdftops for over 3 years, and so far, only one person has had a problem, while on the other hand, at one site where I installed it, it has been processing about 1000 files a week including fixing several files each week with RGB images.  So the optimization has about 300 wins to 1 loss.

In any case, if you think that it is better, I can make a new patch to make the default preserve the color space and add a -optimizecolorspace option that enables the optimization.
Comment 3 Adrian Johnson 2015-02-05 08:47:46 UTC
I noticed the problem with source.pdf is the PS output is using a fallback image which is output in two parts each with a different colorspace. We should keep the fallback images all in the same colorspace.
Comment 4 Benjamin Lefevre 2015-02-05 15:02:22 UTC
Created attachment 113199 [details]
my print without preservecolorspace option
Comment 5 Benjamin Lefevre 2015-02-05 15:04:01 UTC
Created attachment 113200 [details]
my print without preservecolorspace option (zoom)
Comment 6 Benjamin Lefevre 2015-02-05 15:04:34 UTC
Created attachment 113201 [details]
my print with preservecolorspace option
Comment 7 Benjamin Lefevre 2015-02-05 15:08:12 UTC
Hello guys

Many thanks to you. And a special thank to William for your patch.
It definitively solves my issue encountered on some printers.

Please look at the pictures in attachments. With and without preservecolorspace option. 

Now, my 2 cents. I'm agree with Adrian, I would propose to not change the colorspaces by default, and have a new option to propose optimization of colorspaces.

Do you think this request has a chance to be provided with a future release of poppler?
Comment 8 William Bader 2015-02-05 16:28:48 UTC
Thanks for testing it.  Yes, Adrian has a good point.  I will make an -optimizecolorspace tonight where the default is to preserve the color space and you need to use the option to optimize it.
I am not a poppler developer, so the decision of which patch to apply is not up to me.
William
Comment 9 Benjamin Lefevre 2015-02-05 16:33:47 UTC
:-)
Comment 10 William Bader 2015-02-05 21:09:39 UTC
Created attachment 113208 [details] [review]
Alternate patch that adds -optimizecolorspace

This patch reverts the optimization change from a few years ago.
pdftops will preserve the color space by default.
The patch provides the new option -optimizecolorspace to enable the optimization.
Comment 11 Albert Astals Cid 2015-02-05 22:00:13 UTC
You're not initializing optimizeColorSpace in PSOutputDev
Comment 12 William Bader 2015-02-06 00:16:31 UTC
Created attachment 113211 [details] [review]
Updated alternate patch to add -optimizecolorspace

Sorry about that. Here is a new patch.
Comment 13 Albert Astals Cid 2015-02-06 00:41:01 UTC
Can you please add the option to the manpage?
Comment 14 William Bader 2015-02-06 01:16:20 UTC
Created attachment 113213 [details] [review]
Updated alternate patch to add -optimizecolorspace with man page

I added a man page entry.

By the way, after I added the initialization, I checked that valgrind was clean when running pdftops on source.pdf with and without the new option.

Also, I noticed that -aaRaster is not in the man page.  I didn't add it in the patched here to avoid confusion.  If you want, I can add man page patches to https://bugs.freedesktop.org/show_bug.cgi?id=85934

Is there a preferred method for setting boolean options? The pdftoxxx utilities have some flags like -preload that are set just by using them and others like -aaVector that take yes/no parameters.
Comment 15 Albert Astals Cid 2015-02-07 15:40:11 UTC
Yes please, add the man page change there, about flag or text, no idea, just check what's the most common :D
Comment 16 Albert Astals Cid 2015-02-07 15:42:32 UTC
Pushed
Comment 17 Benjamin Lefevre 2015-02-09 09:05:35 UTC
Thanx guys
Comment 18 Benjamin Lefevre 2015-02-18 08:39:45 UTC
Hi guys, 

Is there a chance that the bug is fixed in the next release? if yes, do you know when it will occur? It seems there is about one release per month, doesn't it?
Comment 19 Albert Astals Cid 2015-02-18 18:36:09 UTC
Yes, yes


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.