Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io
- import urllib.request
- from PIL import Image, ImageDraw, ImageFont
- def pic(fdc: str, txt: str):
- fd = urllib.request.urlopen(fdc)
- image_file = io.BytesIO(fd.read())
- im = Image.open(image_file)
- font = ImageFont.truetype(r'C:\Users\MAX-Ryzen\Desktop\Roboto\Roboto-Black.ttf', size=75)
- draw_text = ImageDraw.Draw(im)
- width, height = draw_text.textsize(txt, font=font)
- position: tuple = ((im.width - width) / 2, im.height - 100)
- draw_text.text(position, txt, font=font, fill='#FF0000')
- return im.show()
- pic('https://squarefaction.ru/files/game/3927/gallery/20150403133829_ab1991b9.jpg',
- 'Как же прекрасно Таврово')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement