Skip to content

Instantly share code, notes, and snippets.

@drhanlau
Created June 18, 2020 01:50
Show Gist options
  • Save drhanlau/61f6123ff810a317f794577cb82bfdc2 to your computer and use it in GitHub Desktop.
Save drhanlau/61f6123ff810a317f794577cb82bfdc2 to your computer and use it in GitHub Desktop.
from PIL import Image, ImageDraw, ImageFont
img = Image.open('mutton.jpg')
font = ImageFont.truetype('/Library/Fonts/Impact.ttf', 100)
draw = ImageDraw.Draw(img)
def draw_text(x, y, text):
draw.text((x-2, y-2), text,(0,0,0),font=font)
draw.text((x+2, y-2), text,(0,0,0),font=font)
draw.text((x+2, y+2), text,(0,0,0),font=font)
draw.text((x-2, y+2), text,(0,0,0),font=font)
draw.text((x, y), text, (255,255,255), font=font)
draw_text(200,50,"XUE HUA PIAO PIAO")
draw_text(200,900, "BEI FENG XIAO XIAO")
img.save("out.jpg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment