I am trying to write a script in python which delivers functionality of ink coverage same as Ghostscript. I dont know where to start. Can someone please guide me?
This depends on whether you want to handle PostScript or PDF as an input.
In either event you will need to write an interpreter for the language, and a rendering library. Its believed that an interpreter and rendering library for PostScript is around 5 man years work. Although PDF is at first sight simpler, because it is a description language, not a programming language, the more complex graphics model (transparency for example) and complications like annotations, optional content etc will likely make this a task of similar or greater magnitude.
luser droog, who has written an at least reasonably complete PostScript ineterpreter, can possibly provide more detailed estimates of the effort involved.
So, once you can interpret the input, and render it, then you can count the number of pixels of each colour in your rendered output. That will give you the ink coverage. That part is very simple....
Of course, even more simply, just use Ghostscript and take advantage of something like 100 man years of development that's already been done.
Ghostscript ink coverage function in python