Hi, I'm hoping maniac-ga sees this question. You did a fantastic job
for the person who wanted this answer for LINUX, but I'm looking for
the same answer in a Windows32 OS. The subject line of that question
was "Toner coverage calculator from PS/PDF files for Linux" at
http://answers.google.com/answers/threadview?id=496406 |
Request for Question Clarification by
maniac-ga
on
17 Aug 2005 19:38 PDT
Hello Parveez68,
I assume you find the solution identified by smsimms-ga is inadequate.
http://avpsoft.com/products/apfill/
which has a 30 day trial version at
http://avpsoft.com/download/apfill.exe
What other kind of solution are you looking for? For example, I could suggest:
- taking an older PC (otherwise suitable for retirement), installing
Linux, and following the Linux instructions already provided [plus the
set up for printing from MS Windows]
- using the "Lexmark Color Estimator" (supplied with several Lexmark
printers) to determine the toner usage. See
http://reviews-zdnet.com.com/Lexmark_C510_series/4505-3159_16-30794777-4.html
for a brief review of the C510 printer series w/ the estimator
described as the "best feature" plus some pricing of the printer.
- a similar product from Canon (MircoPress), described briefly at
http://www.canon.ca/products/viewall.asp?lng=en&gid=1&sgid=27&prodid=419&ovr=1
though this appears to be the same as
http://www.efi.com/products/micropress/index.fhtml
(previously from T/R Systems) see also
http://www.printondemand.com/MT/archives/004430.html
for a joint press release by Canon / EFI
- use of DocXplorer (search for that phrase for several good
references) as part of a document production system.
- investigating the build of percentblank, percentcolor, and
percent_cmy for Windows (most likely running under cygwin and related
utilities. This would be basically an application similar to APFill
but not integrated with the Windows printing system.
http://www.cygwin.com/
Each solution has a different cost / benefit. Which of these (or all
of them) should I expand on?
--Maniac
|
Clarification of Question by
parveez68-ga
on
18 Aug 2005 12:24 PDT
Hi Maniac,
Thanks for your question -- the last option you mentioned looks the
most suitable solution for me because it would provide a command-line
interface which is the most important factor. Specifically, I would
need to process print documents in batch mode, so I imagine a (GNU or
other?) script of some sort (equivalent to DOS batch files anyway)
would allow me to do that.
Also, one other clarification is that I would not want to be limited
to only being able to process PS or PDF files, so the final solution
would also need to allow for other native formats (JPG, bmp, pcx,
etc...) to be converted into one of the required formats first.
Thanks for your help! I feel very hopeful that you're going to find
this solution for me!
PS - I tried out APFill but the problem with it was that it doesn't
(seem to) have a command-line interface. And the addition of the
GhostScript requirement (required if the calulation is to be based on
the actual doc rather than what's displaye don screen) seemed to be
getting a little cumbersome as it only worked with v8.1.4 and not with
anything newer, so maintenance might become an issue down the road.
|
Request for Question Clarification by
maniac-ga
on
18 Aug 2005 19:20 PDT
Hello Parveez68,
It will be a couple days before I can confirm the build on cygwin. I
will also suggest some file conversion programs as well (those that
can be scripted) to handle the other file formats.
--Maniac
|
Hello Parveez68,
It looks like there is a good solution to what you asked for. The
following steps should work on your system.
[1] Download the Cygwin setup program
http://cygwin.com
(the download link is near the middle of the page)
[2] Run setup.exe. The first time, I suggest just taking the defaults
which will download some programs and help make sure you get
reasonable performance from the server you selected. I looked at
http://cygwin.com/mirrors.html
to find a site relatively close to my system.
(I chose the one at anl.gov, but others may be closer to your system /
have better performance for your situation).
[3] Make sure the basic install works. Select the desktop icon (if
installed) or the start menu selection. You should get a command line
window. Try some simple commands like
ls [which lists the files in the "current directory"]
ls /bin [which lists a set of executable programs]
pwd [which prints the name of the "current directory" with path]
man man [which describes an online manual system]
man bash [which will describe more than you want about the "shell" commands]
[4] Download / install the other applications needed. Run setup.exe
again and when given the list of packages, click on the "+" symbol to
show details in the categories and select the packages listed below
(and any others you find interesting...).
Development
- gcc (the C compiler)
- make (optional - to run the build script)
- gdb (optional - command line debugger)
- ddd (optional - visual debugger)
Graphics
- ImageMagick (for converting files to PNG)
- ghostscript (convert PS to bitmaps)
- libpng12 (for building the application)
Web
- wget (optional - to download printbill)
[note - this selection will download several other packages as well /
based on dependencies of the packages]
On a cable modem and using the anl.gov server, it took several minutes
(but well less than an hour) to download the files selected.
[4] Download and extract printbill - I suggest you put it into an
otherwise empty directory for testing. The directory on my system was
on the "D" drive and I used
cd /cygdrive/d/Maniac/google/
to go into the directory referred to D:\Maniac\google\ by Windows.
Modify that command line to go into the directory you have. If there
are spaces in the path, be sure to use quotes ("" or '') around the
path.
I used the commands
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
which worked as described in the previous answer.
[5] Build the applications. I found the Makefile did not work properly
under Cygwin, and used the following command lines instead.
gcc percent_cmy.c -Wall -O2 -lpng12 -lm -o percent_cmy
gcc -o percentblack percentblack.c -Wall -O2 -lpng12 -lm
gcc -o percentcolour percentcolour.c -Wall -O2 -lpng12 -lm
[some slight variation - the commands are basically equivalent]
[6] Find a png file to test the applications. I did the following:
find / -name "*.png" -print
and ran percentcolour with one of the files listed
./percentcolour.exe /usr/share/doc/ImageMagick-6.0.4/images/logo.png
to get the result
12.814:13.325:8.158:2.198:1
[7] Find a ps file to test the use of ghostscript / and the
applications. I did the following:
find / -name "*.ps" -print
and ran gs with one of the files listed
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r150 \
-sOutputFile='paper-%00d.png' /usr/share/doc/bzip2-1.0.3/manual.ps
[this step did take less than 20 seconds to process 38 pages]
to generate a number of "page" files which were processed as
for N in paper-*.png ; do ./percentcolour.exe $N; done
which printed out
0.000:0.000:0.000:1.219:1
0.000:0.000:0.000:4.466:1
0.031:0.031:0.000:3.773:1
0.000:0.000:0.000:5.739:1
0.000:0.000:0.000:4.700:1
0.000:0.000:0.000:2.792:1
1.330:1.330:0.614:3.661:1
1.045:1.045:0.482:3.775:1
0.000:0.000:0.000:4.377:1
2.742:2.742:1.266:2.001:1
0.612:0.612:0.268:3.435:1
0.000:0.000:0.000:2.464:1
0.811:0.811:0.374:3.060:1
1.679:1.679:0.775:2.506:1
1.158:1.158:0.534:3.487:1
0.703:0.703:0.324:2.168:1
2.122:2.122:0.980:2.215:1
1.396:1.396:0.644:2.096:1
2.028:2.028:0.936:1.518:1
1.093:1.093:0.505:3.878:1
1.795:1.795:0.829:2.300:1
2.257:2.257:1.041:2.319:1
0.000:0.000:0.000:2.904:1
1.211:1.211:0.559:2.917:1
1.958:1.958:0.904:2.707:1
0.118:0.118:0.054:4.481:1
0.000:0.000:0.000:1.609:1
0.000:0.000:0.000:5.227:1
0.000:0.000:0.000:4.522:1
0.406:0.406:0.187:4.989:1
2.685:1.193:1.641:2.973:1
1.117:0.496:0.682:0.904:1
0.110:0.110:0.000:1.615:1
0.000:0.000:0.000:1.849:1
0.000:0.000:0.000:5.127:1
0.059:0.059:0.000:4.012:1
0.349:0.349:0.134:4.791:1
0.749:0.749:0.346:5.059:1
This kind of output could be directed to a file or further processed.
[8] As part of "ImageMagick" is a file conversion program "convert".
The simplest is to find a suitable file using something like
find / -name "*.jpg" -print
and then run convert
convert /usr/share/doc/ImageMagick-6.0.4/images/ImageMagick.jpg ./im.png
and then run percentcolur as
./percentcolour.exe ./im.png
14.172:13.767:12.031:0.166:1
At this point, I believe I have covered all the steps to generate the
toner coverage information. A simple script to process a postscript
file follows:
#!/bin/sh
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r150 \
-sOutputFile='paper-%00d.png' $1
for N in paper-*.png ; do
./percentcolour.exe $N
\rm $N
done
name it something like gs.sh and then
chmod +x gs.sh
to make it executable and
./gs.sh /usr/share/doc/bzip2-1.0.3/manual.ps
to test it.
A simple script to process several graphic files is:
#!/bin/sh
for N in $@ ; do
convert $N temp.png
./percentcolour.exe temp.png
\rm temp.png
done
name it something like graphic.sh, make it executable, and then run like
./graphic.sh /usr/share/doc/ImageMagick-6.0.4/images/*.jpg
That sequence touches on all the key points and I believe gives you
some scripts to adapt for your needs. Please make a clarification
request if ANY step does not work as described - I did my testing on
Windows 2000 (where I have administrator access), but it should work
on any recent Windows system.
--Maniac |
Request for Answer Clarification by
parveez68-ga
on
28 Aug 2005 18:47 PDT
Hi Maniac,
Thanks for the very detailed answer. Once this all works it's going to
be perfect. I'm up to step 5, and I got the following error message
from gcc when trying to compile percent_cmy.c:
percent_cmy.c:28:17: png.h: No such file or directory
...which I assume must be resolved first and is causing the subsequent
error messages in the list. Also, i need to ask for your help in
clarifying the gcc command line parameters you specified -- I can't
tell the difference between a lower case L and a digit one; or a
capital letter 'O' and a digit zero. If you could please clarify that,
I suppose it might just also be the cause of the png.h error.
Thanks. I'm looking forward to getting this to work.
|
Clarification of Answer by
maniac-ga
on
28 Aug 2005 19:56 PDT
Hello Parveez68,
> I'm up to step 5, and I got the following error message
> from gcc when trying to compile percent_cmy.c:
>
> percent_cmy.c:28:17: png.h: No such file or directory
> ...which I assume must be resolved first and is causing the subsequent
> error messages in the list.
I agree. It should have been provided by the package libpng12. Check
that you have it - if so, try downloading the package libpng as well
[from the description at the cygwin site - they should be just
slightly different versions of the png library package - I did both in
my testing but did not notice any difference]. I will get access to
the Windows machine I have with cygwin tomorrow and I'll check the
location of png.h to help diagnose the problem.
> Also, i need to ask for your help in
> clarifying the gcc command line parameters you specified -- I can't
> tell the difference between a lower case L and a digit one; or a
> capital letter 'O' and a digit zero.
In the command line:
gcc percent_cmy.c -Wall -O2 -lpng12 -lm -o percent_cmy
the "O" is an "oh" and the "l" letters are "ell's". To clarify the command line:
percent_cmy.c - the source file
-Wall - turns on [almost] all warnings
-O2 - the optimization level (two selects optimization w/o code growth)
-lpng12 - selects the library named libpng12
-lm - selects the library named libm (a standard math library)
-o percent_cmy - the output file (executable)
I will check back in tomorrow.
-Maniac
|
Request for Answer Clarification by
parveez68-ga
on
28 Aug 2005 23:27 PDT
Thanks for the clarification on the command line paramaters. And, as I
already had libpng12 installed (i.e., according to the 'Graphics'
category when I ran setup.exe again, libpng12 showed with a 'Keep'
beside it) so I also chose to get libpng as you suggested.
However, I got the same (or very similar) error msgs again (about the
png.h file and so on) so I think I'll take one step back to make sure
I haven't missed something important.....
In your step [4], the wget seems to work fine but after I unzip the
file using the tar command, the directory created is simply
'printbill_4.1.2' without the '-1' at the end of the directory name as
you show it in step 4. Is this a symptom of a problem at this stage?
If I choose to cd into the created directory as it has been created,
the src subdirectory and several other files and directories are
there, so maybe this isn't a real issue.
One other question, in case this is what's been fouling things up: is
it okay that I did the wget from within the directory
/home/Parveez/google ?
I'll wait to hear from you tomorrow. Thanks for your help!
Parveez
|
Clarification of Answer by
maniac-ga
on
29 Aug 2005 08:05 PDT
Hello Parveez68,
What you describe sounds OK to me.
I did a quick check on the locations of the libraries and include files:
$ find /lib -name "*png*" -print
/lib/libpng.a
/lib/libpng.dll.a
/lib/libpng12.a
/lib/libpng12.dll.a
/lib/pkgconfig/libpng.pc
/lib/pkgconfig/libpng12.pc
[the first two are the static / dynamic libraries for the package
"libpng", the second two are the same for "libpng12" and the last two
appear to be some package configuration files for cygwin]
$ find /usr/include -name "*png*" -print
/usr/include/libpng
/usr/include/libpng12
/usr/include/libpng12/png.h
/usr/include/libpng12/pngconf.h
/usr/include/png.h
/usr/include/pngconf.h
[the first two are directories, the second two are the header files
for libpng12, and the last two are links to the real locations...]
Checking the default file (/usr/include/png.h) location I get.
$ ls -l /usr/include/png.h
lrwxrwxrwx 1 maniac mkgroup-l-d 23 Aug 19 21:53 /usr/include/png.h
-> /etc/alternatives/png.h
[pointing to a file in /etc/alternatives/]
$ ls -l /etc/alternatives/png.h
lrwxrwxrwx 1 maniac mkgroup-l-d 27 Aug 19 21:53
/etc/alternatives/png.h -> /usr/include/libpng12/png.h
[pointing to the libpng12 version]
$ ls -l /usr/include/libpng12/png.h
-rwxrwxrwx 1 maniac mkgroup-l-d 142306 Jul 11 17:50 /usr/include/libpng12/png
.h
[the real file being used]
You should get similar output on your system - let me know if these
links are broken and I can suggest a fix. It could be something as
simple as:
cd /usr/include
rm png.h
ln -s libpng12/png.h png.h
--Maniac
|
Request for Answer Clarification by
parveez68-ga
on
29 Aug 2005 09:36 PDT
Hi Maniac,
Thanks for the syntax of the find command. Now we know something basic
has gone wrong earlier during the install itself because
$ find / -name "png.h" -print
yields nothing at all. When I first got this result Iwent back to
setup.exe and checked to see if I had missed anything. Please confirm
that these options I chose in setup.exe are okay:
1. Install type: "Install from Internet"
2. Root Directory: C:\CYGWIN
3. Install for: All Users
4. Deafult Text File Type: Unix
5. When the categories are displayed, the "Curr" radio button is
selected at the top of the screen.
Then, under the Graphics category, I chose to "Re-install" the
packages you listed, and this time I selected the src checkbox as
well, which at first I was sure had caused the problem. But the find I
tried above still returned nothing.
Now I am questioning whether I am in fact choosing the correct
packages from the list in setup.exe, because there are a lot of items
to choose from that are 'similar' to libpng12 (ie, a lot of them
contain the phrase libpng in them, and about those two columns Bin?
and Src? -- I don't know what they're supposed to be for)
So could you please elaborate on step [4] by listing exactly the names
of each package I'm supposed to select and what each row should look
like when I've properly selected it (eg, selected checkbox or not, n/a
or n/q or whatever that is (and what does that mean anyway?)
If you can take a screenshot or 2 or 3 or 4 of what that selection
screen looks like and mail them to me that will probably be the
quickest and surest. My address is parveez68 adt ya?h?oo?.c#a
Thanks
Parveez
|
Clarification of Answer by
maniac-ga
on
29 Aug 2005 11:56 PDT
Hell Parveez68,
Hmm. After looking at the inside the packages I downloaded, it looks
like you need libpng12-devel or libpng10-devel; my mistake. The other
packages appear to have a runtime library only and not the header
files.
Run Setup and download and intall one of these two packages and you
should get the header files, libraries, and other materials.
--Maniac
|
Request for Answer Clarification by
parveez68-ga
on
29 Aug 2005 15:01 PDT
Hi Maniac,
Yes that fixed it. Thanks. Now that I've been able to look at the
output and test it on a couple of jpg files I've created, I have one
last question, which maybe you've answered already and I've missed,
but here it is....
Please correct me if any of my following understanding is wrong:
I can see that the output from perdentcolour.exe etc... is a series of
ratios where each number in the ratio corresponds to the ratio of
Cyan, Magenta, Yellow and Black used to print the image file.
What I don't know how to do yet is use this output, or some other
output I'm not aware I have access to, to figure out the actual
amount, in absolute terms, of toner being used. In other words, With
only the ratios as output, an image would yield the same output as the
same image magnified by a factor of 4. So, how can get an answer that
sounds like:
"When printed, this image will have used 0.002 ml of Cyan, 0.0015 ml
of Magenta, etc..."
and so that the amounts given in the answer should be appropriately
reduced if the image is reduced in dimension before feeding it to
percentcolour.exe again.
I hope my question makes sense.
Thanks
Parveez
|
Clarification of Answer by
maniac-ga
on
29 Aug 2005 15:49 PDT
Hello Parveez68,
Let's see - how to convert the percentages into something more useful.
Most printer cartridges are rated as something like:
- 450 pages assuming 5% coverage
- $20 per cartridge
So doing a little math:
- $20.00 / 450 = $0.04444 per page (assuming 5% coverage)
or
- 20 x $20.00 / 450 = $0.8888 per page (assuming 100% coverage)
or
- $20.00 / (450 * 5) = $0.008888 per page (assuming 1% coverage)
or round up to $0.01 per percent per page - especially if you have a
three color cartridge which will likely run out before you use all of
the three colors.
[replace the figures I used with ones that match your printing device]
That last factor ($0.01 per percent per page) could be used directly
to convert the percentage ink usage to dollars for the pages processed
by ghostscript.
It is a little more complicated when dealing with other images. You
would like to scale the cost by the size of the image. For example, if
I am printing a photograph, the total coverage (unless there is a LOT
of white) is going to be in the 90% to 100% range but likely on a much
smaller page (e.g., 4 x 6). The formula would be closer to:
- (20 x $20.00) / (450 x 4) = $0.22 per photo
[20 x higher percentage on 1/4 the size of paper]
You could modify the program to scale the output based on the size of
the image (e.g. rows & columns) but that would require you to assume
the pixels per inch are uniform on all the file types. The output from
ghostscript meets that but doing that in general with different image
types will be an interesting challenge.
--Maniac
|