def genimage(infilename,outfilename,pos=(10,10),fill=(255,255,255,64),stroke_fill=(0,0,0,64),stroke_width=4,fontsize=100,pictext=f"я тутъ\nнаговнокодилъ"): infilename = f"pics/"+infilename if os.path.isfile(infilename): with Image.open(infilename).convert("RGBA") as im: # im = Image.open(infilename).convert("RGBA") size = im.size # imtxt = Image.new('RGBA', im.size, (255,255,255,0)) with Image.new('RGBA', im.size, (255,255,255,0)) as imtxt: font = ImageFont.truetype(f"fonts/FRADMCN.TTF", fontsize) d = ImageDraw.Draw(imtxt) d.multiline_text(pos, pictext, stroke_width=stroke_width, , stroke_fill=stroke_fill, font=font, fill=fill) with Image.alpha_composite(im, imtxt) as combined: combined.save(f"outpics/"+outfilename) return True else: return False