Fanning Software Consulting

Mac Preview Adds Colors to PostScript Files

Facebook Twitter RSS Google+

QUESTION: I made a discrete color bar with only 10 colors using your cgColorbar program, but when I view the PostScript file, I see 256 colors. What's going on? I thought the major benefit of your programs is that they work in PostScript exactly as they work on the display? Indeed, this program works perfectly on the display.

ANSWER: This is not a problem with the cgColorbar program. Rather, it is a problem with the Preview application on the Macintosh that you are using to view the PostScript file. Somehow, in translating the PostScript file to a PDF file, which is what is viewed, these extra, nonexistent colors get added. They don't exist in the file, and they would not appear if you were using a different PostScript viewer. MacGhostView and PostView are two inexpensive PostScript viewers I have heard good things about, although I have no personal experience, since I don't own a Mac. You may already have GhostView installed on your computer. Any of these three viewers will show the PostScript file as it actually exists.

I'm told that the same problem exists if the PostScript file is imported into the Mac Powerpoint application. In both cases, it would be better to convert the PostScript file to a PDF (cgPS2PDF) or raster file (cgPS2Raster) before you either view them with the Preview application or import them into Powerpoint.

Phillip Bitzer, in a recent IDL newsgroup article, had this additional information to share about this problem.

Like David said, this is not a problem with the file or cgColorbar, but I don't think this is a "problem" exactly with Preview either - it seems to be an issue with aliasing. Consider the program below, which is similar to yours (note I don't load in a color bar, rather I specify the RGB palette). After producing the eps file, open it in Preview. You'll probably see the graduated colors, which I think is what you are reporting.

If you go to Preferences->PDF, and toggle the Check box for "Smooth text and line art", then you will see your discrete color bar reappear. The text won't look as nice, however. This is an issue with the default aliasing used by Preview. Smoothing introduces the graduated colors you see.

Here, for example, is the non-smoothed result, with anti-aliasing turned off.

The non-smoothed, anti-aliasing off result.
The non-smoothed, anti-aliasing off result.
 

And, here is the smooth result, with anti-aliasing turned on.

The smoothed, anti-aliasing on result.
The smoothed, anti-aliasing on result.
 

The code I used to produce the figures can be found here.

Version of IDL used to prepare this article: IDL 7.1.2.

Written: 5 November 2012
Updated 7 November 2012