Python PILLOW generated text is in the wrong position

I am working on a python script to create data input into a pre-created image. For this, I use Python PILlon, and I am developing in Windows 7.

I am struggling with the draw.text () function, in which I enter the position (0,0). Unfortunately, the text is placed in a bunch of pixels down.

Firstly, I thought it was my mistake, I searched the Internet and found the page http://tools.jedutils.com/tools/center-text-image , where the code for (in the center, but the problem is the same same) is as follows:

def create_image(font_name, font_size, font_color, width, height, back_ground_color, text, image_filter=None):

font  =  ImageFont.truetype ( font_path + font_name + ".ttf", font_size )

im  =  Image.new ( "RGB", (width,height), back_ground_color )
draw  =  ImageDraw.Draw ( im )
text_x, text_y = font.getsize(text)
x = (width - text_x)/2
y = (height - text_y)/2
draw.text ( (x,y), text, font=font, fill=font_color )

#if filter: #i don't need given filter
#    real_filter = filter_dict[image_filter]
#    im = im.filter(real_filter)
im.save ( "runaway_emboss.jpg" )

, , script. , , Windows Fonts *.py, . .

:

: Bad : Good

- , ?

+4

All Articles