also fix return value of drawText
This commit is contained in:
parent
440c7ad49b
commit
a871ecb3c5
1 changed files with 7 additions and 1 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue