Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ascii_art_python

PyPI version Python versions PyPI Downloads License: MIT

A powerful and flexible Python library and Command Line Interface (CLI) to convert your images and videos into stunning ASCII art.

ascii_art_python uses advanced edge detection (via OpenCV) and luminosity mapping to generate high-quality ASCII representations. It supports multiprocessing for fast video conversion and even transfers original audio tracks to your ASCII videos!

Preview

Below is an example of an image featuring the Python logo:

              ||=*|{||#&&&&||||||              
              /##--\&&&&&&&&&&$$&\\            
            |&&|  |{&&&&&&&&&$$$$\             
            |&&\--/&&&&&&&&&$$$$$|             
            :\-#####---\&&$$$$$$$|             
      ------/;;;;;;;===|$$$$$$$$$|  -----      
    /--##&&&&&----------/$$$$$$$$@| .:::::-\\  
  //#####&&&&&&&&&&&&$$$$$$$$$$$@| .:::::::\\  
  //&####&&&&&&&&&&&$$$$$$$$$$$$$@| .::::::::\ 
  |####&&&&&&&&&&$$$$$$$$$@@@@@@@//.:::::::::| 
  |&#&&&&&&&&&$$-----------------..:::::::::::|
  |&&&&&&&&&&//-.................:::::::::::::|
  |&&&&&&&&&// ..::::::::::::::::::::::::::;;| 
  |&&&&&&&$| ::::::::::::::::::::::::::;;;;;/  
  \\&&&&&$$| :::::::::::::::::::::::;;;;;;;//  
    \\$$$$$@| ::::::::::::::::::;;;;;;;;;;;//  
      ------/ ::::::::::...........--------    
              ::::::::::\---::::--|/           
            |::::::::::::;;/--\;;|             
            |\::::::::;;;;;|  |;;|             
              \\::::;;;;;;;;\--:;//            
              \---:;;;;;;;;;::--/              
                  ------------                 

And below, an example of a video featuring Nyan Cat:

Example with the Nyan Cat video played.

Features

  • Image to ASCII: Convert standard images (JPG, PNG, etc.) to ASCII strings or export them as PNG files.

  • Video to ASCII: Convert entire video files to ASCII animations (MP4 format) with original audio preserved.

  • Command Line Interface: Quickly convert files directly from your terminal.

  • Three Rendering Modes:

    • full_mode: Combines edge detection and background luminosity for highly detailed art.

    • old_skool: Uses directional characters based on edge detection (perfect for a "Matrix" look).

    • new_skool: Uses background characters mapped by luminosity.

  • Terminal Playback: Play ASCII videos or display images directly within your console.

Installation

Install the package easily via pip:

pip install ascii_art_python

Command Line Interface (CLI) Usage

The library provides convenient commands to process your media right from the terminal.

Display directly in the terminal

Automatically resizes the output to fit your current terminal window.

# Display an image (default full_mode)
aap my_image.jpg

# Play a video with the 'old_skool' edges-only style
aap my_video.mp4 -m old_skool

# Play a video with the 'old_skool' edges-only style from Youtube
aap "https://www.youtube.com/watch?v=dQw4w9WgXcQ" -m old_skool

Export to a file

Saves the ASCII output to your disk (.png for images, .mp4 for videos).

# Export an image with a specific width and 'new_skool' mode
aap landscape.jpg -o landscape_ascii -w 150 -m new_skool

# Export a complete video and keep the original audio track
aap music_video.mp4 -o ascii_clip --sound -f 10

Python API Usage

You can also integrate ascii_art_python directly into your own Python scripts.

import ascii_art_python as aap

# --- 1. Image Conversion ---
# Load an image and set a target width
img = aap.Image.from_path("my_image.jpg", width=120)

# Print it to the console
print(img.to_string(old_skool=True, new_skool=True, one_on_two=True))

# Or export it as a PNG file
img.export(filename="my_ascii_image", font_size=15, old_skool=True, new_skool=True)

# --- 2. Video Conversion ---
# Load a video (processing at 15 FPS)
video = aap.Video("my_video.mp4", width=80, wanted_fps=15)

# Export the video with sound (uses multiprocessing for speed)
video.export(filename="my_ascii_video", sound=True, old_skool=True, new_skool=True)

Prerequisites

This program requires ffmpeg to process videos. Before using this script, make sure to install it on your system:

  • macOS:

    brew install ffmpeg
    
  • Windows:

    winget install ffmpeg
    # or
    choco install ffmpeg
    
  • Linux (Debian/Ubuntu):

    sudo apt update && sudo apt install ffmpeg
    
  • Linux (Fedora/Arch):

    sudo dnf install ffmpeg   # Fedora
    sudo pacman -S ffmpeg     # Arch Linux
    

Full Documentation

To check the complete API, class details, and advanced export options, visit: the doc.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Download files

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

Source Distribution

ascii_art_python-3.0.0rc0.tar.gz (304.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ascii_art_python-3.0.0rc0-py3-none-any.whl (307.6 kB view details)

Uploaded Python 3

File details

Details for the file ascii_art_python-3.0.0rc0.tar.gz.

File metadata

  • Download URL: ascii_art_python-3.0.0rc0.tar.gz
  • Upload date:
  • Size: 304.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for ascii_art_python-3.0.0rc0.tar.gz
Algorithm Hash digest
SHA256 d2bbe9a57cb8b2ffde84bf1f5fbf05ffec528ee33c910d52acb1724520e5a29d
MD5 cd7101043063582cbaad6d8ffaed392a
BLAKE2b-256 6c3ad1138c6ac01a101d8cd4c66d5071013b95d6ba9d1c7433653738080c8d3e

See more details on using hashes here.

File details

Details for the file ascii_art_python-3.0.0rc0-py3-none-any.whl.

File metadata

File hashes

Hashes for ascii_art_python-3.0.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 39d28a72055e2bf28984b709a58ac97a556676c0f715f0cce915d80f59526a24
MD5 77a9516097b66e24ed5208c3927ef9a7
BLAKE2b-256 d003602897d1b0777c0d4168db2b18ec0da9b546bf932ef544503527f5a4e97e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0.0rc0 This release

2 files

2.1.1

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page