Skip to main content

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
Note: In some cases, you might get the error "No module named 'exceptions'". This is because the docx and python-docx libraries are not installed properly.
You can try the library extensively on Jupyter notebook. Create a copy of this notebook and make edits as necessary.
Also, in case of 'exception like too many values to unpack', try using a jpg image.
This library works best with JPG images

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

Metadata

Release files for asciimage 3.141592653

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asciimage 3.141592653
File Size Uploaded Provenance
asciimage-3.141592653.tar.gz 4.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for asciimage 3.141592653
File Interpreter ABI Platform
asciimage-3.141592653-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 kB

Release files / asciimage-3.141592653.tar.gz

Download URL asciimage-3.141592653.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4905e3373969bfd5bb9d2948e84770f99524ab009373cdc6019c3bdb69b7bf35
BLAKE2b-256 checksum
How to use checksums
5640c2f68c7fbb769fde4d87cfc7597b8a1b33cdd21983f4d0885fd05a4b4c76
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / asciimage-3.141592653-py3-none-any.whl

Download URL asciimage-3.141592653-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f66a987c49b7c6012627f433f83e07e08d532178a9eee30b3ed28955fa618188
BLAKE2b-256 checksum
How to use checksums
aabfba326ee69a8e63404a91099a0b8036e09c2894b45258e1a07e669d10aa92
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for asciimage 3.141592653

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page