Skip to content

Instantly share code, notes, and snippets.

@shravankumar147
Last active March 16, 2020 19:32
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 shravankumar147/184b2c896d77afc902cbc025000d3c3d to your computer and use it in GitHub Desktop.
Save shravankumar147/184b2c896d77afc902cbc025000d3c3d to your computer and use it in GitHub Desktop.
from PIL import Image, ImageDraw, ImageFont
import sys
ShowText = sys.argv[1]
font = ImageFont.truetype('arialbd.ttf', 15) #load the font
size = font.getsize(ShowText) #calc the size of text in pixels
image = Image.new('1', size, 1) #create a b/w image
draw = ImageDraw.Draw(image)
draw.text((0, 0), ShowText, font=font) #render the text to the bitmap
def mapBitToChar(im, col, row):
if im.getpixel((col, row)): return ' '
else: return '='
for r in range(size[1]):
print(''.join([mapBitToChar(image, c, r) for c in range(size[0])]))
@shravankumar147
Copy link
Author

generate ascii art with python, generate logos on command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment