Changeset 442 for pkpgcounter/trunk/pkpgpdls/inkcoverage.py
- Timestamp:
- 12/16/06 21:44:34 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/inkcoverage.py
r439 r442 49 49 if img.mode != "RGB" : 50 50 img = img.convert("RGB") 51 data = img.getdata()52 51 cyan = magenta = yellow = black = 0 53 for (r, g, b) in data:52 for (r, g, b) in img.getdata() : 54 53 if r == g == b : 55 54 black += 255 - r … … 66 65 def getPercentGC(img, nbpix) : 67 66 """Determines if a page is in grayscale or colour mode.""" 68 result = getPercentCMYK(img, nbpix) 69 if result["C"] == result["M"] == result["Y"] == 0.0 : 70 return { "G" : 100.0, "C" : 0.0 } 71 else : 72 return { "G" : 0.0, "C" : 100.0 } 67 if img.mode != "RGB" : 68 img = img.convert("RGB") 69 gray = 0 70 for (r, g, b) in img.getdata() : 71 if not (r == g == b) : 72 # optimize : if a single pixel is no gray the whole page is colored. 73 return { "G" : 0.0, "C" : 100.0 } 74 return { "G" : 100.0, "C" : 0.0 } 73 75 74 76 def getPercentBW(img, nbpix) :