Google Answers Logo
View Question
 
Q: Toner coverage calculator from PS/PDF files for Linux ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Toner coverage calculator from PS/PDF files for Linux
Category: Computers > Software
Asked by: smsimms-ga
List Price: $30.00
Posted: 17 Mar 2005 14:41 PST
Expires: 16 Apr 2005 15:41 PDT
Question ID: 496406
Where can I find a Linux command-line utility to report b&w/color
coverage in a PDF or PS file?

It must be able to report color and black coverage separately, either
as a percentage or absolute values, in such a way that it can be
called and read from another program.  Open source would be nice, but
isn't required.  If it can separate out CMYK, all the better.

It must be able to handle multiple-page PDF or PS files, or
instructions must be provided on how to automatically (i.e. via a
script) split these out into separate files -- I'll accept either.

For an example of a Windows program that does the same sort of thing,
search for APFill.  I want to pull similar numbers automatically, from
Linux.
Answer  
Subject: Re: Toner coverage calculator from PS/PDF files for Linux
Answered By: maniac-ga on 17 Mar 2005 19:41 PST
Rated:5 out of 5 stars
 
Hello Smsimms,

I am not quite sure of your application so I will provide a few links
you may find helpful if you need something beyond what you immediately
ask for.

The best method to do what you ask can be done in a few, relatively
easy steps. If some step is not described sufficiently or is unclear -
do not hesitate to make a clarification request and I would be glad to
expand on the answer.

[1] Take your PS or PDF file and feed to Ghostscript to generate a PNG
file for each page. Something like:
  gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r150 \
         -sOutputFile='paper-%00d.png' paper.ps
will rasterize paper.ps to create a series of files paper-001.png,
paper-002.png, and so on.

Note that Ghostscript has a LOT of options so if you want color or
black and white, adjust the command line to be appropriate. See
  http://www.cs.wisc.edu/~ghost/doc/index.htm
for extensive documentation on both major versions of Ghostscript (GNU, AFPL),
  http://www.gnu.org/software/ghostscript/devices.html
for a list of supported devices (for GNU Ghostscript) or use
  man gs
or
  info gs
or
  gs -h
on your Linux system for more information on gs options / capabilities.

[2] Process the PNG file(s) and compute the amount of black (or color)
on each page and print out the result. I found a set of three C
programs that appear to fit the bill. They are:
 - percentblack.c - computes black coverage (as a percent)
 - percentcolour.c - computes color coverage (as a percent)
 - percent_cmy.c - computes color for each of the three colors (as a percent)
I read through the source of these [but have not built them] and they
appear to do a good job at computing the percentages you need.

If you need cmyk, the accurate result will likely be based on some
"threshold" for black and vary by printer. Perhaps modifying
percent_cmy to compare each pixel is >250 for all three colors would
be a good compromise (instead of using 255 for each) but I am not
sure. If you make this change, be sure to not "double" count the
pixels that are black. Make a clarification request if you need the
coding for this change.

To get these programs, download "printbill" from Debian (a Linux
distribution) and build the three files in the "src" directory (after
expanding the tar file). Something like
  wget http://ftp.debian.org/debian/pool/main/p/printbill/printbill_4.1.2-1.tar.gz
  tar xzf printbill_4.1.2-1.tar.gz
  cd printbill_4.1.2-1/src
  make
should do the bill. [though if you need to debug one of the programs,
I suggest not stripping the binaries before attempting to debug them -
let me know if you want this explained]

I am not sure if "printbill" is currently maintained but it is free
software. The Debian bug list has a few bugs, all about 2 years old.
The Freshmeat entry has also been removed. Search using a phrase like
  printbill Debian
to bring up pages describing the application. The site in Australia
where the author maintained several pages (search with)
  site:uow.edu.au printbill 
did not respond to my inquries; use the Google cache to see the HOWTO
and other documents.

[3] A simple script that should process the files created in step 1
and run the program in step 2 could be as simple as:

  $!/bin/sh
  for N in *.png ; do
    percent_cmy $N
  done

(assuming percent_cmy is in your PATH - if not, use the full path)
Refer to
  man bash
on your Linux system or
  http://www.cs.sunysb.edu/documentation/bash/bash.html
for more information on the "Bourne Again Shell".

If you are trying to bill based on ink usage, I suggest using
printbill directly. The HOWTO in particular describes the set up for
Debian as well as describing the steps for a Red hat system.

There was also a nice comparison between billing applications I found at
  http://www.librelogiciel.com/software/PyKota/pykota-vs-printbill-vs-printquota-vs-pquotas.html
if you want some other alternatives for comparison. [it was this
article that lead me to printbill and the source code to analyze
PNG's]

This information should be sufficient to do what you asked for
directly. If you need something a little different or are having
problems with the download or build of the application - please make a
clarification request. I would be glad to help further.

  --Maniac
µ
smsimms-ga rated this answer:5 out of 5 stars and gave an additional tip of: $10.00
This is exactly what I wanted.  Thank you for the great detail!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy