also fix return value of drawText

This commit is contained in:
j 2014-11-20 12:50:33 +00:00
parent 440c7ad49b
commit a871ecb3c5

View file

@ -25,7 +25,13 @@ def drawText(image, position, text, font_file, font_size, color):
draw = ImageDraw.Draw(image)
font = ImageFont.truetype(font_file, font_size, encoding='unic')
draw.text(position, text, fill=color, font=font)
return draw.textsize(text, font=font)
size = draw.textsize(text, font=font)
version = getattr(Image, 'PILLOW_VERSION', None)
if version and version > '2.1.0' and version < '2.6.1':
offset = font.getoffset(text)
else:
offset = (0, 0)
return (size[0] + offset[0], size[1] + offset[1])
def getHSL(rgb):
rgb = [x / 255 for x in rgb]