Skip to content

Instantly share code, notes, and snippets.

@a2chub
Created May 27, 2020 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a2chub/d7663f94616eb5eb35565ab6ff83460a to your computer and use it in GitHub Desktop.
Save a2chub/d7663f94616eb5eb35565ab6ff83460a to your computer and use it in GitHub Desktop.
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
call_sign = "JI1SVR"
# base image
im = Image.new("RGB",(288, 72),"#00ff00")
palettedata = [0,0,0, 0,255,0, 255,255,255]
font_size = 20
fnt_reg = ImageFont.truetype('./fonts/Nasu-Regular-20200227.ttf', font_size)
fnt_bld = ImageFont.truetype('./fonts/Nasu-Bold-20200227.ttf', font_size-1)
draw = ImageDraw.Draw(im)
shadow_shift = 0
draw.text((0 + shadow_shift, 32+shadow_shift),call_sign, font=fnt_bld, fill=(0,0,0))
draw.text((0, 32),call_sign, font=fnt_reg)
im.save("./with_CS.png")
im2 = Image.open("./with_CS.png")
im2.quantize(3, kmeans=True).convert("RGB")
im2.save("./with_CS_four.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment