To start off, I'm assuming that for grays where r=g=b, that getcolor(name, 'L') should return the same as getcolor(name, 'RGB') [0]. Integer division done too early rounds down, so grays end up slightly too dark in grayscale modes. Here's the line in question (PIL 1.1.6, ImageColor.py line 108):
return r*299/1000 + g*587/1000 + b*114/1000All the true grays except black (that is, darkgray, dimgray, gray, lightgray, and white) exhibit this issue. The one that made me notice this is that 'white' means 254 instead of 255. With the attached patch, it now behaves sanely, i.e.:
Image.new('RGB', (1, 1), color).convert('L').getpixel((0, 0)) == Image.new('L', (1, 1), color).getpixel((0, 0))
for all named colors, and ImageColor.getcolor(color, 'L') == ImageColor.getcolor(color, 'RGB')[0] for the grays. Tim
imagecolor-rounding.diff
Description: Binary data
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig