Changeset 281 for pkpgcounter/trunk/pkpgpdls/inkcoverage.py
- Timestamp:
- 11/08/05 00:40:05 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/inkcoverage.py
r280 r281 81 81 def getPercents(fname) : 82 82 """Extracts the ink percentages from an image.""" 83 try : 84 import psyco 85 except ImportError : 86 pass 87 else : 88 psyco.bind(getPercentCMYK) 89 result = [] 90 index = 0 83 91 image = Image.open(fname) 84 nbpixels = image.size[0] * image.size[1] 85 black = getPercentBlack(image, nbpixels) 86 rgb = getPercentRGB(image, nbpixels) 87 cmy = getPercentCMY(image, nbpixels) 88 cmyk = getPercentCMYK(image, nbpixels) 89 print "Black : ", black 90 print "RGB : ", rgb 91 print "CMY : ", cmy 92 print "CMYK : ", cmyk 92 try : 93 while 1 : 94 nbpixels = image.size[0] * image.size[1] 95 result.append({ "BLACK" : getPercentBlack(image, nbpixels), \ 96 "RGB" : getPercentRGB(image, nbpixels), \ 97 "CMY" : getPercentCMY(image, nbpixels), \ 98 "CMYK" : getPercentCMYK(image, nbpixels), \ 99 }) 100 index += 1 101 image.seek(index) 102 except EOFError : 103 pass 104 return result 93 105 94 106 if __name__ == "__main__" : 95 getPercents(sys.argv[1]) 107 # NB : length of result gives number of pages ! 108 print getPercents(sys.argv[1])