Skip to main content

small tool to transfer image between cmd char

Project description

image2char

description

this module can change image to char[], can be printed at console beautiful

effect:

-->

-->

this QR Code can even be recognized when density>=0.6

quick start

from image2char import tool
from PIL import Image
import logging

img_path1 = 'image2char/input1.jpg'
img_path2 = 'image2char/input2.png'

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    img1 = Image.open(img_path1)
    img2 = Image.open(img_path2)
    
    matrix = tool.to_chars(img1, density=0.5, scale=2, reversed=True)
    logging.info('matrix: %d, %d' % (len(matrix), len(matrix[0])))
    for i in range(len(matrix)):
        print(''.join(matrix[i]))

    char_list = '''█ '''
    scanner = tool.get_scanner(density=0.6, scale=1)
    # reversed=True: in windows console, the char is white
    scanner.scan(img2, reversed=True, char_list=char_list)
    scanner.print_result()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image2char-0.0.5.tar.gz (13.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page