Page 1 of 1

PS delegate substitution rules

Posted: 2009-06-23T07:17:21-07:00
by cmcfarling
Imagemagick 6.3.7
Ghostscript 8.64

delegates.xml states:
For delegates other than ps:alpha, ps:color, ps:mono, and mpeg-encode the substitution rules are as follows
and then lists all of the substitution rules. What about the substitution rules for ps:* delegates, what are they?

I'm trying to tweak the way IM invokes GS but am having difficulty. For example I want to remove dGraphicsAlphaBits=%u from the ps:cmyk delegate. However when I do so IM fails to generate any output. It appears to be something to do with the %u variable but I don't have the details on why this would be.

Re: PS delegate substitution rules

Posted: 2009-06-23T07:42:36-07:00
by magick
The Postscript delegates are non-standard. If you do not intend to delete the TextAlphaBits option you can simply repeat it-- that is change "-dTextAlphaBits=%u -dGraphicsAlphaBits=%u" to "dTextAlphaBits=%u -dTextAlphaBits=%u". Otherwise you will need to edit coders/ps.c and modify the FormatMagickString() statement that populates these embedded formating strings (i.e. %u).

Re: PS delegate substitution rules

Posted: 2009-06-23T08:56:58-07:00
by cmcfarling
That pointed me in the right direction. The actual problem I was trying to solve had to do with colors being rendered incorrectly. I have an older IM install that has been converting EPS/PDF to JPEG for years. I recently tried to duplicate that setup using a newer version of IM. The old version was pre-XML delegate files. I could tweak the ps:* delegates easily with no adverse side effects. It appears that now the ps:* delegates aren't as flexible as they could be. The root cause of my color conversion problems was as follows:

The default ps:cmyk delegate, for example, includes

"-r%s" %s "sOutputFile=%s"

The second %s, it turns out, is a place holder for the -dUseCIEColor switch. Unfortunately you can't just simply remove it if you don't want Ghostscript invoked with the -dUseCIEColor switch. If you do remove it, the string "-dUseCIEColor" is simply applied to the following %s placeholder, effectively changing your output filename to -dUseCIEColor.

The only way to alter this behavior is to edit the source code and recompile from what I gather. Correct me if I'm wrong. If that's the case then that goes against the whole point of the delegates I think, which is to have a way to easily configure external apps that IM invokes. Note that I was able to reslove my particular problem though by adding -dNOCIE to the command string. So I suppose the argument could be made that the ps:* delegates are configurable as they need to be, but to configure them is more of a hack that a straight forward process.

Re: PS delegate substitution rules

Posted: 2009-06-23T09:04:48-07:00
by magick
that goes against the whole point of the delegates I think, which is to have a way to easily configure external apps
Delegates are flexible except these few for Postscript. With our limited brain power it was the best solution we could come up with. If you have a better way to handle this problem, post your patches here and we will get them into a future release of ImageMagick.