[185] | 1 | #! /usr/bin/env python |
---|
[3436] | 2 | # -*- coding: utf-8 -*- |
---|
[185] | 3 | # |
---|
| 4 | # pkpgcounter : a generic Page Description Language parser |
---|
| 5 | # |
---|
[3474] | 6 | # (c) 2003-2009 Jerome Alet <alet@librelogiciel.com> |
---|
[463] | 7 | # This program is free software: you can redistribute it and/or modify |
---|
[185] | 8 | # it under the terms of the GNU General Public License as published by |
---|
[463] | 9 | # the Free Software Foundation, either version 3 of the License, or |
---|
[185] | 10 | # (at your option) any later version. |
---|
[3436] | 11 | # |
---|
[185] | 12 | # This program is distributed in the hope that it will be useful, |
---|
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | # GNU General Public License for more details. |
---|
[3436] | 16 | # |
---|
[185] | 17 | # You should have received a copy of the GNU General Public License |
---|
[463] | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
[185] | 19 | # |
---|
| 20 | # $Id$ |
---|
| 21 | # |
---|
| 22 | # |
---|
| 23 | |
---|
[211] | 24 | import sys |
---|
[235] | 25 | from pkpgpdls.version import __version__, __author__, __authoremail__, \ |
---|
[223] | 26 | __years__, __gplblurb__ |
---|
[235] | 27 | from pkpgpdls import analyzer |
---|
[186] | 28 | |
---|
[223] | 29 | __doc__ = """pkpgcounter v%(__version__)s (c) %(__years__)s %(__author__)s |
---|
| 30 | |
---|
| 31 | pkpgcounter is a generic Page Description Language parser. |
---|
| 32 | |
---|
| 33 | pkpgcounter parses any number of input files and/or its standard input |
---|
| 34 | and outputs the number of pages needed to print these documents. |
---|
| 35 | |
---|
[369] | 36 | pkpgcounter can also compute the percent of ink coverage in different |
---|
| 37 | colorspaces for several file formats. |
---|
[223] | 38 | |
---|
[375] | 39 | pkpgcounter currently recognizes the following document formats : |
---|
[369] | 40 | |
---|
[223] | 41 | * PostScript (both DSC compliant and binary) |
---|
[528] | 42 | * PDF |
---|
[223] | 43 | * PCLXL (aka PCL6) |
---|
[528] | 44 | * PCL3/4/5 |
---|
[223] | 45 | * DVI |
---|
[528] | 46 | * OpenDocument (ISO/IEC DIS 26300) |
---|
[529] | 47 | * Microsoft Word (c) (tm) (r) (etc...) |
---|
[418] | 48 | * Plain text |
---|
[223] | 49 | * TIFF |
---|
[502] | 50 | * Several other image formats |
---|
[223] | 51 | * ESC/P2 |
---|
[329] | 52 | * Zenographics ZjStream |
---|
[386] | 53 | * Samsung QPDL (aka SPL2) |
---|
[418] | 54 | * Samsung SPL1 |
---|
[476] | 55 | * ESC/PageS03 |
---|
[480] | 56 | * Brother HBP |
---|
[485] | 57 | * Hewlett-Packard LIDIL (hpijs) |
---|
[539] | 58 | * Structured Fax |
---|
[545] | 59 | * Canon BJ/BJC |
---|
[549] | 60 | * ASCII PNM (Netpbm) |
---|
[223] | 61 | |
---|
[549] | 62 | The ten latter ones, as well as some TIFF documents, are currently |
---|
[528] | 63 | only supported in page counting mode. |
---|
[369] | 64 | |
---|
[223] | 65 | command line usage : |
---|
| 66 | |
---|
| 67 | pkpgcounter [options] [files] |
---|
| 68 | |
---|
| 69 | options : |
---|
| 70 | |
---|
[369] | 71 | -v | --version Prints pkpgcounter's version number then exits. |
---|
| 72 | -h | --help Prints this message then exits. |
---|
[3436] | 73 | |
---|
| 74 | -d | --debug Activate debug mode. |
---|
| 75 | |
---|
[369] | 76 | -cCOLORSPACE, --colorspace=COLORSPACE |
---|
| 77 | Activate the computation of ink usage, and defines the |
---|
[439] | 78 | colorspace to use. Supported values are 'BW' (Black), |
---|
| 79 | 'RGB', 'CMYK', 'CMY', and 'GC' (Grayscale vs Color). |
---|
[3436] | 80 | 'GC' is useful if you only need to differentiate |
---|
[439] | 81 | grayscale pages from coloured pages but don't care |
---|
| 82 | about ink usage per se. |
---|
[3436] | 83 | |
---|
[369] | 84 | -rRESOLUTION, --resolution=RESOLUTION |
---|
| 85 | The resolution in DPI to use when checking ink usage. |
---|
| 86 | Lower resolution is faster but less accurate. Default |
---|
| 87 | is 72 dpi. |
---|
[223] | 88 | |
---|
[3436] | 89 | examples : |
---|
| 90 | |
---|
[223] | 91 | $ pkpgcounter file1.ps file2.escp2 file3.pclxl <file4.pcl345 |
---|
[3436] | 92 | |
---|
[223] | 93 | Will launch pkpgcounter and will output the total number of pages |
---|
| 94 | needed to print all the documents specified. |
---|
[3436] | 95 | |
---|
[369] | 96 | $ pkpgcounter --colorspace bw --resolution 150 file1.ps |
---|
[3436] | 97 | |
---|
[369] | 98 | Will output the percent of black ink needed on each page of |
---|
[374] | 99 | the file1.ps file rendered at 150 dpi. |
---|
[223] | 100 | |
---|
[3436] | 101 | %(__gplblurb__)s |
---|
| 102 | |
---|
[223] | 103 | Please e-mail bugs to: %(__authoremail__)s""" |
---|
| 104 | |
---|
[3436] | 105 | if __name__ == "__main__" : |
---|
[211] | 106 | if (len(sys.argv) >= 2) and (sys.argv[1] in ("-h", "--help")) : |
---|
[3456] | 107 | sys.stdout.write("%s\n" % (__doc__ % globals())) |
---|
[3436] | 108 | else : |
---|
[211] | 109 | analyzer.main() |
---|