Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine color info for pages 1

Status
Not open for further replies.

cheyney

Programmer
Jul 16, 2002
335
CA
I am wondering if there is a way to determine what pages of a postscript contain color information and what pages contain only black&white/grayscale.

I am assuming I will have to use a postscript interpreter like ghostscript, but I don't know where to start.

Any help would be greatly appreciated,

Cheyney
 
Cheyney,

This is so nearly impossible it's best to give up now. Without rasterizing the file and looking at each pixel, there really isn't a good way to do this.

You can't just do a keyword search, for example for "setcmykcolor". Many PostScript drivers and applications define all sorts of colorspaces and operators even if they never use them.

Then too, you have to check not just operators but parameters. Is .5 .5 .5 setrgbcolor a color? Or a shade of gray?

Then you have device-independent colorspaces, LAB colors and CIE, /DeviceN colors and Spot Colors. Are you going to maintain a lookup table of all Pantone Colors? Are all Pantone grays really grays?

You begin I hope to see the problem.

If you have some control over the PostScript (for example, you're only looking at output from a single application on a stable platform with a driver that doesn't change), then you can slowly whittle away at this.

Good luck!

Thomas D. Greer
 
ugh, ok thanks :)

I kindof expected that much...

The application I'm developing has a certain degree of human interaction for each file, so I'll probably do what you said and rasterize the postscript into a series of suitably-high resolution bitmaps and then look at the pixels to determine if there's any color in the file. Less than perfect, I know, but its quick and easy to implement and probably good enough. The process currenly produces jpegs for each postscript anyway. all I need is a quick little c program that looks at the color info for each pixel.

Thanks for your help, you've probably saved me more than a couple hours of research.

Cheyney
 
Don't forgget that the color vs. black-and-white property depends on the CDR installed on the device. You need to copy CRD;s from your target inteerpreter to Ghostscript before rasterizing.

--
Your PostScript consultant is just a click away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top