Overriding postscript /setcmykcolor

人走茶凉 提交于 2020-07-09 12:13:25

问题


I'm trying to change the color from EPS files that contain only vectors (no rasters). Currently, I convert them to SVG, manipulate the colors, and convert them back to PDF or EPS with Inkscape. This works perfectly but doesn't allow me to apply CMYK coloring, only RGB. After investigating a little bit and finding answers like this or this I'm trying to override the /setcmykcolor function my EPS file uses. You can download it from here.

The EPS looks like this:

And I want to convert the color to CMYK = 0 1 1 0 so it looks like this:

In this case, the EPS file is black but it could be any other color. I tried adding this after %%BeginProlog which should override the /setcmykcolor to always apply 0 1 1 0 as the CMYK color:

/osetcmykcolor {/setcmykcolor} bind def /setcmykcolor {pop [0 1 1 0] osetcmykcolor} def

Or this:

/osetcmykcolor {/setcmykcolor} bind def /setcmykcolor {0 1 1 0 osetcmykcolor} def

But everything is still black. I know /setcmykcolor is the right function because using 0 1 1 0 setcmykcolor just before drawing the path makes it red. I went through postscript programming manuals but I'm having a hard time trying to figure out what's wrong here!

Any help would be greatly appreciated!


回答1:


If I start Ghostscript then do :

GS> /osetcmykcolor /setcmykcolor load def
GS> /setcmykcolor {pop pop pop pop 0 1 1 0 osetcmykcolor} bind def
GS> (color.eps) run

then the EPS is rendered in 'orange' as you expect.

Note that setcmykcolor takes 4 arguments so you have to pop all 4 (though this won't be causing a lack of colour, its just leaving junk on the stack).

Editing the EPS file:

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 564 454
%%HiResBoundingBox: 0.00 0.00 564.00 453.20
%%Creator: GPL Ghostscript 921 (eps2write)
%%LanguageLevel: 2
%%CreationDate: D:20200616000003-03'00'
%%Pages: 1
%%EndComments
%%BeginProlog
/osetcmykcolor /setcmykcolor load def
/setcmykcolor {pop pop pop pop 0 1 1 0 osetcmykcolor} bind def
/DSC_OPDFREAD true def

and then running it with:

gs color1.eps

also produces orange text. So how are you testing it ?



来源:https://stackoverflow.com/questions/62419312/overriding-postscript-setcmykcolor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!