Conversion ToolsHow can I generate a PS using RGB colors only with DVIPS/gs?

Information and discussion about output converters related to LaTeX (e.g. dvips, ps2pdf, ...)
Post Reply
kreyszig
Posts: 11
Joined: Tue Jan 26, 2010 4:30 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by kreyszig »

Hi,

I want to produce a postscript file that uses only RGB colors with DVIPs, but DVIPs includes color.pro which defines basic colors using CMYK values. color.pro defines setcmykcolor using setrgbcolor when it is undefined:

Code: Select all

/setcmykcolor where{pop}{/setcmykcolor{dup 10 eq{pop
setrgbcolor}{1 sub 4 1 roll 3{3 index add neg dup 0 lt{pop 0}if 3 1 roll
}repeat setrgbcolor pop}ifelse}B}ifelse
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
but somehow setcmykcolor is already defined though when I use

gs -dPDFA -dPDFACompatibilityPolicy=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite

in a later stage to produce my PDF file, resulting in the usage of CMYK values. How can I prevent this from happening?

Thanks!
Last edited by kreyszig on Tue Nov 09, 2010 4:35 pm, edited 4 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by CrazyHorse »

kreyszig wrote: I want to produce a postscript file that uses only RGB colors with DVIPs, but DVIPs includes color.pro which defines basic colors using CMYK values. color.pro defines setcmykcolor using setrgbcolor when it is undefined:

/setcmykcolor where{pop}{/setcmykcolor{dup 10 eq{pop
setrgbcolor}{1 sub 4 1 roll 3{3 index add neg dup 0 lt{pop 0}if 3 1 roll
}repeat setrgbcolor pop}ifelse}B}ifelse

Somehow setcmykcolor is already defined though, resulting in the usage of CMYK values in the PS file. How can I prevent this from happening?

Code: Select all

\usepackage[rgb]{xcolor}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Herbert
kreyszig
Posts: 11
Joined: Tue Jan 26, 2010 4:30 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by kreyszig »

CrazyHorse wrote:

Code: Select all

\usepackage[rgb]{xcolor}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Herbert
I use that already in LaTeX. What this does is to rewrite my own colors using RGB, but it does not prevent dvips from using the color.pro header file which uses CMYK. The color.pro header would work fine if setcmykcolor was undefined when I use

gs -dPDFA -dPDFACompatibilityPolicy=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite

in a later stage to produce my PDF file, but for some reason gs defines setcmykcolor even when using DeviceRGB, so it fails at converting everything to setrgbcolor...
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by CrazyHorse »

kreyszig wrote:
CrazyHorse wrote:

Code: Select all

\usepackage[rgb]{xcolor}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I use that already in LaTeX. What this does is to rewrite my own colors using RGB, but it does not prevent dvips from using the color.pro header file which uses CMYK. The color.pro header would work fine if setcmykcolor was undefined when I use

gs -dPDFA -dPDFACompatibilityPolicy=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite

in a later stage to produce my PDF file, but for some reason gs defines setcmykcolor even when using DeviceRGB, so it fails at converting everything to setrgbcolor...
Sorry, but in color.pro is only a definition for setcmykcolor but it does
not mean that it is already used. However, you can overwrite /setcmykcolor:

Code: Select all

Code, edit and compile here:
\AtBeginDocument{\special{ps:
/setcmykcolor { 10 dict begin
/K exch def
/K1 1 K sub def
/Y exch def
/M exch def
/C exch def
1 C K1 mul K add sub
1 M K1 mul K add sub
1 Y K1 mul K add sub
setrgbcolor
end
} def
}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Herbert
kreyszig
Posts: 11
Joined: Tue Jan 26, 2010 4:30 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by kreyszig »

CrazyHorse wrote: Sorry, but in color.pro is only a definition for setcmykcolor but it does
not mean that it is already used. However, you can overwrite /setcmykcolor:

Code: Select all

Code, edit and compile here:
\AtBeginDocument{\special{ps:
/setcmykcolor { 10 dict begin
/K exch def
/K1 1 K sub def
/Y exch def
/M exch def
/C exch def
1 C K1 mul K add sub
1 M K1 mul K add sub
1 Y K1 mul K add sub
setrgbcolor
end
} def
}}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Herbert
Thanks for the code, this is a good idea. I had verified in the ps file that setcmykcolor was used/defined for the first time in the code read from color.pro. What I had done is to copy color.pro in my directory and load it via the DVIPSHEADERS environment variable. For now I am defining setcmykcolor using the code from the original color.pro that used to be executed only when setcmykcolor was undefined, but what I could eventually do is to simply rewrite the basic color values using RGB directly. setcmykcolor is only used to define the basic colors in my ps file (due to the usage of the xcolor pacakage with the option rgb). I still find weird that gs defines setcmykcolor when using DeviceRGB, but I guess I have a way around it now. I just need to check if Preflight is finally happy with my PDF/A...
kreyszig
Posts: 11
Joined: Tue Jan 26, 2010 4:30 am

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by kreyszig »

For those interested, here is a redefinition of the basic colors of color.pro using RGB values exclusively.

Code: Select all

TeXDict begin/Rhodamine{1 0.18 1 setrgbcolor}N/OliveGreen{0 0.6 0 setrgbcolor}N/Mahogany{0 0 0.65 setrgbcolor}N/BlueGreen{0.67 1 0.15 setrgbcolor}N
/PineGreen{0.16 0.75 0 setrgbcolor}N/Sepia{0 0 0.3 setrgbcolor}N/RedOrange{0.13 0.23 1 setrgbcolor}N/Lavender{1 0.52 1 setrgbcolor}N
/Apricot{0.48 0.68 1 setrgbcolor}N/Turquoise{0.8 1 0.15 setrgbcolor}N/Maroon{0.0 0 0.68 setrgbcolor}N/Magenta{1 0 1 setrgbcolor}N
/White{1 1 1 setrgbcolor}N/VioletRed{1 0.19 1 setrgbcolor}N/YellowOrange{0 0.58 1 setrgbcolor}N/Orchid{1 0.36 0.68 setrgbcolor}N
/CadetBlue{0.77 0.43 0.38 setrgbcolor}N/YellowGreen{0.26 1 0.56 setrgbcolor}N/Red{0 0 1 setrgbcolor}N/Cerulean{1 0.89 0.06 setrgbcolor}N
/BrickRed{0 0 0.72 setrgbcolor}N/Aquamarine{0.7 1 0.18 setrgbcolor}N/RedViolet{0.66 0 0.59 setrgbcolor}N/ProcessBlue{1 1 0.04 setrgbcolor}N
/DarkOrchid{0.8 0.2 0.6 setrgbcolor}N/Cyan{1 1 0 setrgbcolor}N/SeaGreen{0.5 1 0.31 setrgbcolor}N/BurntOrange{0 0.49 1 setrgbcolor}N
/GreenYellow{0.31 1 0.85 setrgbcolor}N/RubineRed{0.87 0 1 setrgbcolor}N/CarnationPink{1 0.37 1 setrgbcolor}N/LimeGreen{0 1 0.5 setrgbcolor}N
/Periwinkle{1 0.45 0.43 setrgbcolor}N/Green{0 1 0 setrgbcolor}N/Bittersweet{0 0.01 0.76 setrgbcolor}N/Fuchsia{0.92 0.01 0.45 setrgbcolor}N
/Mulberry{0.98 0.08 0.64 setrgbcolor}N/Violet{1 0.12 0.21 setrgbcolor}N/BlueViolet{0.96 0.05 0.1 setrgbcolor}N/Orange{0.13 0.39 1 setrgbcolor}N
/Melon{0.5 0.54 1 setrgbcolor}N/OrangeRed{0.5 0 1 setrgbcolor}N/Salmon{0.62 0.47 1 setrgbcolor}N/Thistle{1 0.41 0.88 setrgbcolor}N
/RawSienna{0 0 0.55 setrgbcolor}N/Blue{1 0 0 setrgbcolor}N/Dandelion{0.16 0.71 1 setrgbcolor}N/Purple{1 0.14 0.55 setrgbcolor}N
/RoyalBlue{1 0.5 0 setrgbcolor}N/SpringGreen{0.24 1 0.74 setrgbcolor}N/MidnightBlue{0.57 0.44 0 setrgbcolor}N/Peach{0.3 0.5 1 setrgbcolor}N
/Emerald{0.5 1 0 setrgbcolor}N/Brown{0 0 0.4 setrgbcolor}N/RoyalPurple{1 0.1 0.25 setrgbcolor}N/WildStrawberry{0.61 0.04 1 setrgbcolor}N
/Gray{0.5 0.5 0.5 setrgbcolor}N/NavyBlue{1 0.46 0.06 setrgbcolor}N/Black{0 0 0 setrgbcolor}N/JungleGreen{0.48 1 0.01 setrgbcolor}N
/Plum{1 0 0.5 setrgbcolor}N/Tan{0.44 0.58 0.86 setrgbcolor}N/CornflowerBlue{1 0.87 0.35 setrgbcolor}N/TealBlue{0.64 0.98 0.12 setrgbcolor}N
/SkyBlue{0.88 1 0.38 setrgbcolor}N/Yellow{0 1 1 setrgbcolor}N/Goldenrod{0.16 0.9 1 setrgbcolor}N/ForestGreen{0.0 0.88 0 setrgbcolor}N
/TeXcolorrgb{setrgbcolor}N/TeXcolorcmyk{setcmykcolor}def/TeXcolorgrey{setgray}def/TeXcolorgray{setgray}def/TeXcolorhsb{sethsbcolor}def
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
when combined with LaTeX using the package xcolor with the option rgb and when the PS document is converted to PDF using

Code: Select all

gs -dPDFA -dPDFACompatibilityPolicy=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
it allows to generate a document complying with PDF/A-1b (according to Adobe Acrobat Preflight) that uses DeviceRGB. Of course you have to also include the meta information as required... I use the appropriate options in hyperref to include it...
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

How can I generate a PS using RGB colors only with DVIPS/gs?

Post by localghost »

Now that the problem seems to be solved, please be so kind and mark the topic (not the last post) accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Otherwise please tell us what is missing. Please keep that in mind for the future so that further reminders will not be necessary.


Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply