Skip to main content

ASCII art Python library

Project description

asciimage

A library designed in python to convert images into ascii paintings. To install:

pip install asciimage
pip install docx
pip install python-docx
For more exmamples or if you are still struggling with installation check out the Jupyter notebook

Table of Contents

  1. Installation
  2. Motivation
  3. Example
  4. Sample
  5. Troubleshooting

Installation

The repository contains a zipped file of my Python package asciimage and should be installed via pip.
Instalation procedure:
pip install asciimage
pip install docx
pip install python-docx
#The docx and python-docx libraries must be installed

Motivation

The package is intended as a simple drawing tool that produces ASCII art.
The user will upload an image. The image has to be a jpg or png image. The image should have a nice contrast for proper output.
The package contains the function make_ascii_image() which produces ascii art
For the colored ASCII image function, the input images should not be very richly colored and the function works well for images of small size, up to dimensions 256X256.

Example

This is the way to run the module:

	from asciimage import *
	from PIL import Image #import the module
	image_path = r"input_image.jpg"
	file_path = r"output.txt" #'output.txt' is the destination where the ASCII art will be stored
	ascii_char = list(",.")
	height = 400 #intended height of output file
	width = 400 #intended width of output file
	art = asciimage(image_path,file_path,ascii_char,height,width) #optional: ascii_char,height,width
	art.make_ascii_image()

	#for colored ascii image
	from PIL import Image
	from docx import *
	from docx.shared import *
	image_path = r"input_image.jpg"
	file_path = r"output.doc" #'output.doc' is the destination where the ASCII art will be stored
	art = asciimage(image_path,file_path) #compulsory: image_path,file_path
	#this function outputs a doc file only
	art.make_colored_ascii(64)#produces 64X64 image; 

Sample

Input Image:
input

Output text file:
output

Colored ASCII Input Image:
input

Output doc file:
output

If you like the library, please consider giving it a star on Github :)

Troubleshooting

This is a common error:
input If this happens, it is because of python-docx not being installed. In that case, please proceed with:
pip install python-docx
pip install docx

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

asciimage-3.14159265.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

asciimage-3.14159265-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file asciimage-3.14159265.tar.gz.

File metadata

  • Download URL: asciimage-3.14159265.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for asciimage-3.14159265.tar.gz
Algorithm Hash digest
SHA256 a7b86d28d899abbe5c1bbdb5846e0699f58c8cf5a71230625ba29c8fa0bb7ade
MD5 abf3a1f35d80e621eccbf8ddeb811ea5
BLAKE2b-256 98a7940e66d35c5e7bb18c0ab120d7ad50b0ed431aea50a3eb1cf0cc9d8123ce

See more details on using hashes here.

File details

Details for the file asciimage-3.14159265-py3-none-any.whl.

File metadata

  • Download URL: asciimage-3.14159265-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for asciimage-3.14159265-py3-none-any.whl
Algorithm Hash digest
SHA256 7876e29d0926f1296f0ebf79def9fcb1f29828985dd8b7e6c485bc9c6ab2e63c
MD5 b27090326bd6ab0df847a2f6315aac57
BLAKE2b-256 addbab838ce025128d32b553a57ddf533712b4dd3170b912972e8de113f2a14f

See more details on using hashes here.

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