I am generating a PDF where all the graphics are drawn in \\DeviceRGB in the sRGB color space. I would like to convert the PDF into a different Color Profile using an ICC pr
AFAIU, Ghostscript 9.12-9.27 is unable to do what you expect.
But you might be able to partially achieve your goals:
Try UseDeviceIndependentColor.
This won't embed your profile, and won't convert colors to your profile. But it would make you colors "colorimetrically defined" and would embed some icc profile. If your aim is to "preserve" colors, that might work for you.
Try PDF/X-3 output, embed "Output Intent" icc profile.
Try to adjust the DefaultRGB colorspace - note the following phrase in the docs:
If a user needs an non trivial color adjustment, a non trivial DefaultRGB color space must be defined
(I've never tried this.)
Try collink. (I've never managed to make this work.)
Original file:
The gs command:
gswin64c -dPDFX -dBATCH -dNOPAUSE -dHaveTransparency=false -r20
-dProcessColorModel=/DeviceCMYK -sColorConversionStrategy=UseDeviceIndependentColor
-sDefaultRGBProfile="default_rgb.icc" -sOutputICCProfile="cmyk_des_renderintent.icc"
-dRenderIntent=1 -dDefaultRenderingIntent=/Perceptual -sDEVICE=pdfwrite
-sOutputFile=colorbar_v1.pdf PDFX_IntCmyk.ps Colorbar.pdf
The output looks like this in Adobe Acrobat (it honors embedded "Output Intent" icc profile):
Same file in Foxit Reader (it ignores embedded "Output Intent"):
What's happening here:
-dHaveTransparency=false makes sure that the 2nd page would get rasterized (due to the presence of a tikz pic with transparency)-r20 makes sure rasterization would be clearly visible (due to just 20dpi)-sOutputICCProfile="cmyk_des_renderintent.icc" -dRenderIntent=1 makes rasterizer produce magenta output.
OutputICCProfile parameter is not mentioned in current docs,
since this (9.27 docs are a bit outdated). RenderIntent is also undocumented in this context. It only affects rasterization as well.-dDefaultRenderingIntent=/Perceptual puts said intent to metadata, alongside "Output Intent icc profile". This makes Acrobat draw everything in cyan.-sDefaultRGBProfile="default_rgb.icc" is a placeholder for possible experiments with input icc profiles. Same default is set if this parameter is omitted.\DefaultRGB), it might be a good idea to explicitly specify the profile here.
Even though sRGB is the default. cmyk_des_renderintent.icc as the "Output Intent".You can find all files used in this experiment here. There are several other experiments as well. I've created them trying to understand how Color Management works in gs. I hope they shed some light on the subject. There's also a comparison with Adobe Acrobat "Convert Colors" tool. AFAIU, it does exactly what you expect.
When it comes to Color Management for pdf output, KenS (gs dev) usually says "the pdfwrite device goes to extreme lengths to maintain color specifications from the input unchanged in the output". It looks like they do not really focus on things like conversion from one profile to another in this case. Well... This is hardly "the most requested" feature.