Last active
March 16, 2020 19:32
-
-
Save shravankumar147/184b2c896d77afc902cbc025000d3c3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
generate ascii art with python, generate logos on command line.