Forum Bugs

Transparent Image and Page Group ColorSpace

yiqiu
We have noticed that page object colorspace is always set to DeviceRGB whenever there is a transparent image in the page.


This was set regardless of the colorspace/profile of the image and there is currently no way to change it.

The understanding is that according to the PDF specification, (Version 1.7 Section 7.3.6), when the colorspace is set on a page object, all colors will be blended into that colorspace before converting to the output device's colorspace.

If not otherwise specified, the page group’s color space is inherited from the native color space of the output device—that is, a device color space, such as DeviceRGB or DeviceCMYK. It is often preferable to specify an explicit color space, particularly a CIE-based space, to ensure more predictable results of the compositing computations within the page group. In this case, all page-level compositing is done in the specified color space, with the entire result then converted to the native color space of the output device before being composited with the context-dependent backdrop. This case also arises when the page is not actually being rendered but is converted to a flattened representation in an opaque imaging model, such as PostScript.


With it set to DeviceRGB currently, we are experiencing significant color distorting with our printer as all the color are translated from CMYK to RGB and back to CMYK.

Is there a way to set a different colorspace, or is it possible to not set the colorspace? According to the spec, it will just inherit the output device's color space in such case?

See attachment for a sample test case where issue.tif is a tiff with DeviceCMYK colorspace.

--
Yiqiu
Software Engineer
Opower
  1. issue.html0.0 kB
  2. issue.tif32.2 kB
  3. page.png38.9 kB

Edited by yiqiu

mikeday
We will take a look at this.
yiqiu
Hello Mike,

Any update on the issue? This is potentially blocking us from using any transparent images since there is no alternative to TIFF in term of lossless transparent graphics that supports CMYK.

--
Yiqiu
Software Engineer
Opower
mikeday
We will provide you with an updated build shortly. Which operating system and architecture are you running Prince on?
yiqiu
We are using CentOS for production machines and OS X for dev machines.

Thanks!

--
Yiqiu
Software Engineer
Opower
mikeday
May I ask which version of CentOS and 32-bit or 64-bit?
yiqiu
It is CentOS6, 64-bit.

Thanks!

--
Yiqiu
Software Engineer
Opower
mikeday
Thank you, we should have new builds ready tomorrow.
mikeday
We now have updated latest builds for MacOS X and CentOS 6 that include a new property to control the colorspace for page compositing:
prince-pdf-page-colorspace: auto | none | rgb | cmyk | gray

The default value is auto, which currently is equivalent to rgb, but in future we may check the colorspace of images that are used on the current page. You may want to try specifying cmyk or none to see which works best for you:
@page {
    prince-pdf-page-colorspace: cmyk
}
yiqiu
Thanks for the quick response, we will test it out.

--
Yiqiu
Software Engineer
Opower
greatislander
Hi @mikeday, Ned from Pressbooks—just wondering about how this works precisely. I tried testing this rule with the latest build of Prince (both running on an Ubuntu 14.04 LTS dev VM and on our CentOS 7 production environment) and it didn't convert images or text into grayscale or cmyk. Am I misinterpreting how this rule is supposed to be used or does this indicate a bug of some kind?
mikeday
This rule only sets the page colorspace that Acrobat uses when compositing, it doesn't actually convert any colors or images itself.

The latest build we just released today includes a new --convert-colors option which will convert all the colors and images in the document to the ICC color profile specified by the --pdf-output-intent option.

Alternatively you can specify --pdf-profile=pdf/x-1a and Prince will automatically convert to CMYK as a consequence of that.
greatislander
Cool! So to recap:

  • To apply the PDF/X-1a profile and convert all text and images to CMYK, we would just need to use the following param:
    --pdf-profile=pdf/x-1a

  • To convert all text and images to grayscale, we would need to supply a grayscale ICC profile file and use the color conversion param:
    --pdf-output-intent=/path/to/grayscale.icc --convert-colors

Is that correct?
mikeday
Yes that is absolutely correct! :D
gabriel.higginbotham
How can this be implemented when not using the command line? In my text there are images with transparent grey borders. These borders become thick grey lines in the PDF output. I am not sure how to change the output type, or if changing that would fix the transparency. My project uses PressBooks.

Thanks!
greatislander
Hi Gabriel, that's a question I can answer better than Mike (I'm the lead dev at Pressbooks). Can you post this in our Discourse and we can continue the discussion there? Thanks.
gabriel.higginbotham
@greatislander I posted the question here: https://discourse.pressbooks.org/t/png-image-transparency/177