Skip to content

Instantly share code, notes, and snippets.

@geconf
geconf / asciiart.py
Last active August 24, 2024 18:22 — forked from wshanshan/asciiart.py
Create ASCII art from an image
from PIL import Image, ImageDraw, ImageFont
from colour import Color
import numpy as np
# The function convert an image to ascii art
# f: Input filename
# SC: the horizontal pixel sampling rate. It should be between 0(exclusive) and 1(inclusive). The larger the number, the more details in the output.
# If you want the ascii art output be the same size as input, use ~ 1/ font size width.
# GCF: >0. It's an image tuning factor. If GCF>1, the image will look brighter; if 0<GCF<1, the image will look darker.
# out_f: output filename