Question

I'm trying to extract the colorspace of an EPS file using Ghostscript. I currently use ImageMagick's identify command but it must rasterize the image before it determines the colorspace. How can I do this with Ghostscript without rasterizing the image?

Was it helpful?

Solution

You've already asked essentially this question here : How can I extract color values from an EPS file?

And I've answered it. EPS files do not have 'a colorspace', they contain marking operations which take place in any of a number of different colour spaces. Because PostScript is a programming language, there is no way to know for certain which colour space(s) are used without interpreting the entire program.

The technique I outlined in my previous answer allows you to 'hook' any of the PostScript marking operations and detect the colour space in force at the time (for images you will have to inspect the dictionary, since they carry the colour space with the arguments).

Your other alternative is to write a Ghostscript device, which will receive all the marking operations and can inspect the current colour space directly, but this is also a great deal of work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top