A python program to generate ANSI art from images and videos

Overview

ANSI Art Generator

A python program that creates ASCII art (with true color support if enabled) from images and videos

Dependencies

The program runs using python3 The following python packages are used in the program:

  • opencv-python
  • Pillow
  • numpy These packages can be installed using any package manager for python like pip, conda, etc.

A Demo

Below is a GIF file (of lesser quality than the original screen-capture) showing the output on a true-color terminal Gif

Usage

Navigate to the directory of the python script and run the following command

python generate.py $FILENAME $OPTION

Here $FILENAME is the full path to the media file and $OPTION takes values 0 for black and white output and 1 for true color output (see if your terminal supports true color before enabling)

My video appears glitchy...

If your video appears glitchy, you can try changing the frame_skip variable to a higher values (instead of 0), in effect dropping the frame-rate. This gives the generator more time to draw the characters to screen.

The image runs out of window...

Again you can change the values of the d2 (height) and d1 (width) variables according to the terminal (Currently they are set to a full-screen terminal on a 13-inch laptop). I am working on a system that can automatically get your terminal size and work accordingly.

TODO

  • Support 3-bit RGB (8-colors) with dithering
  • Support true color (24-bit RGB)
  • Support automatic resizing
  • Support B&W output
Comments
  • Add automatic resizing

    Add automatic resizing

    Use the curses module to detect change in terminal size and automatically resize the video render processes to adapt to it. You can take inspiration and check the size transformation functions in the get_pixel_matrix function.

    enhancement good first issue hacktoberfest-accepted 
    opened by PK-cod3ch3mist 12
  • New logo needed!

    New logo needed!

    The present logo is too simplistic and does not convey graphically the essence of ASCII Media Player. Needed a new logo that is:

    • Minimal (or not if it is really impressive)
    • Conveys the essence of ASCII Media Player and text based interfaces in general
    • In SVG format

    Please discuss and show the logo first in the discussion here before raising a PR.

    enhancement good first issue hacktoberfest-accepted 
    opened by PK-cod3ch3mist 3
  • Add play/pause functionality

    Add play/pause functionality

    Add a command/key that allows user to pause/play the video render

    Add a function that waits for a play pause keypress and in case of the key being pressed/event happening, pauses (or plays) the video, i.e. pauses the rendering at the current frame.

    enhancement good first issue hacktoberfest-accepted 
    opened by PK-cod3ch3mist 3
  • Code Reformat & OOP Construct

    Code Reformat & OOP Construct

    The present code is messy and redundant in many areas. It will be better if the code can be modularised and packaged into one class. It will also allow to wrap the curses function upon the code.

    Requirements:

    • Create a class called AMP that will have all functions in it
    • Remove/merge redundant functions read_media and read_media_sub
    • Add options for tuning the functions
    enhancement good first issue hacktoberfest-accepted 
    opened by PK-cod3ch3mist 2
  • pause funtion with pynput

    pause funtion with pynput

    Hello!

    Here I bring another implementation for the issue with the package pynput that works in linux.

    the idea of the implementation is put a listener in the main script and when "space" is pressed wait until the key is pressed again.

    I have to add a global variable call pause for this implementation, initialize in False.

    Tell me what you think and I hope it helps you.

    opened by JeremiasFuentes 2
  • Add support for 16-colour terminals

    Add support for 16-colour terminals

    The current generator does not support coloured output for terminals with only 16 colours like Terminal.app and Command prompt in Windows. For these, the only option is black and white ascii-graphics.

    • Add a function that determines colour of individual ASCII characters to be printed while converting the image to 16-colours (4-RGB) space.
    • It will be appreciated if done by using dithering so that the image looks similar to the true colour one.
    • Both solutions using openCV/Pillow library functions or a self implementation of dithering are acceptable

    Solutions that sit well with the current code structure, i.e. using options for True-Colour/B&W/4-RGB will be appreciated

    enhancement good first issue hacktoberfest-accepted 
    opened by PK-cod3ch3mist 2
  • Automatic resizing

    Automatic resizing

    Using the os library I created 2 global variables that save the size of the terminal when program starts. Then in a while loop the program checks if the size of the terminal has changed and if it did it updates the video and subtitle windows. I also disabled the cursor so it doesn't ruin the experience.

    No new dependency, only the os library was added. I have changed the import of cv2 library.

    Drawbacks: When the subtitle window is resized the current subtitles might disappear, but only until new subtitles are rendered. I think this is caused by subtitle_show function and how it's implemented.

    opened by Tom712 1
  • Sharpening enhancement

    Sharpening enhancement

    • Added image sharpening enhancement using Laplace filter, this may be used in future to also add edge only rendering (giving a ASCII graphic/drawing effect similar to some other player). Added dependency Scipy.
    • Reformatted the code (for readability).
    • Updated dependencies (program no longer uses Pillow, instead uses OpenCV for all image operations).
    enhancement hacktoberfest-accepted 
    opened by yashee99 1
  • True Colour in Python Curses

    True Colour in Python Curses

    Support for true colour in python curses

    Python curses fulfils almost all the needs for the program (keyboard inputs, timings and delays, seeking), except one. As of yet, python curses doesn't support true colours (it only supports 8 or 16 colors) Therefore, any method to somehow use true colors in python curses is appreciated. In case this is not possible, look at issue #2

    enhancement help wanted question 
    opened by PK-cod3ch3mist 1
  • Added edge only rendering

    Added edge only rendering

    In my previous PR, I mentioned that we could add an edge only rendering mode which mimics the ASCII outline drawing style of programs like figlet (for text) and ASCII star wars (the telnet towel blinken lights one...). Turns out, it isn't that hard to add after edge based sharpening.

    enhancement hacktoberfest-accepted 
    opened by yashee99 0
  • Change from RGB colour model to HSI colour model

    Change from RGB colour model to HSI colour model

    Changes added:

    • RGB to HSI model use, allows for good tuning, and easy brightness operations
    • Code reformat (PR #12)
    • Use of numpy to simplify operations on matrices
    hacktoberfest-accepted 
    opened by PK-cod3ch3mist 0
Releases(v2.1.0)
  • v2.1.0(Oct 14, 2022)

    TL;DR

    In this release,

    • AMP shifts from using RGB colour models to HSI ones for faster and easier conversion and mapping of colour.
    • The code is refactored into a single class.
    • There is now support for play/pause and quit player (in between of a video playback).

    This release continues to use curses module like the previous one. So if you are on windows, you would need to run this on WSL.

    What's Changed

    • Code Reformat and OOPs added by @Vishesh-dd4723 in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/12
    • Change from RGB colour model to HSI colour model by @PK-cod3ch3mist in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/13
    • Directory cleanup by @PK-cod3ch3mist in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/14
    • feat: Keyboard controls by @Vishesh-dd4723 in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/15
    • Flow control by @PK-cod3ch3mist in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/16
    • New logo for ASCII Media Player by @yashee99 in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/19

    New Contributors

    • @Vishesh-dd4723 made their first contribution in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/12
    • @yashee99 made their first contribution in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/19

    Full Changelog: https://github.com/PK-cod3ch3mist/ASCII-Media-Player/compare/v2.0.1...v2.1.0

    Source code(tar.gz)
    Source code(zip)
  • v2.0.1(Apr 3, 2022)

    This is a major update to ASCII Media Player that drops true colour support in favour of achieving compatibility with both old and new terminals. (For example, macOS Terminal.app supported now) If you wish to use the version with true colour support, view previous releases and the tc-version branch of the project.

    What's new

    • added support for terminals only having 8 or 16 colours
    • true colour support has been dropped in favour of greater compatibility and more efficiency
    • added speed control to match frame rate with source video
    • used curses module to achieve improvements
    • dropped pause/play support. Will add it again soon

    Demo of 8-colour support

    https://user-images.githubusercontent.com/55488899/164420738-82087d54-6f61-4ae5-aafb-70a54b923148.mp4

    Source code(tar.gz)
    Source code(zip)
  • v1.2-beta.1(Dec 14, 2021)

    What's changed

    • Removed dependency keyboard in favour of pynput, which is much more friendly to Linux. 🐧
    • Play and pause is now done from the same key, the spacebar. This mimics the functions of other popular video players. 🎥
    • Code restructuring 👨🏻‍💻

    This is a beta release, functions may break, see known bugs below

    Known Bugs

    • Accessibility permissions required for pynput on macOS, visit the pynput documentation for help
    • Too small font sizes may slow the rendering in ASCII for the video.
    Source code(tar.gz)
    Source code(zip)
  • v1.2-beta.0(Nov 12, 2021)

    tl;dr

    To pause, press alt+s. To play, press s when paused. This is a beta release, since the new features have not been thoroughly tested by me

    What's Changed

    • Update README.md by @PK-cod3ch3mist in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/5
    • add play/pause video commands by @JeremiasFuentes in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/6

    New Contributors

    • @JeremiasFuentes made their first contribution in https://github.com/PK-cod3ch3mist/ASCII-Media-Player/pull/6

    Full Changelog: https://github.com/PK-cod3ch3mist/ASCII-Media-Player/compare/v1.1.1...v1.2-beta.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Nov 4, 2021)

    Change Log

    • Removed a bug that caused glitchy output of subtitles
    • Removed multithreaded code since it provided little benefit and took away simplicity
    • Removed bug in the rendering of video
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Oct 31, 2021)

    Added Subtitle Support

    ANSI Art Generator is now AMP That stands for ASCII Media Player. Why the name change? That's because a change in functionality...

    1. ASCII Media Player now supports subtitles, so if you have a .srt file along with the video, AMP will display is on the terminal at the right time.
    2. Groundwork has been added to make AMP more fast in the future through parallelism.
    Source code(tar.gz)
    Source code(zip)
Owner
Pratyush Kumar
Pratyush Kumar
An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright.

Playwright nonoCAPTCHA An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright. Disclaimer This project is for educational

Michael Mooney 69 Dec 28, 2022
Simple Python / ImageMagick script to package images into WAD3s for use as GoldSrc textures.

WADs Out For [The] Ladies Simple Python / ImageMagick script to package images into WAD3s for use as GoldSrc textures. Development mostly focused on L

5 Apr 09, 2022
Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.

django-image-cropping django-image-cropping is an app for cropping uploaded images via Django's admin backend using Jcrop. Screenshot: django-image-cr

Jonas und der Wolf GmbH 546 Jan 03, 2023
Easy to use Python module to extract Exif metadata from digital image files.

Easy to use Python module to extract Exif metadata from digital image files.

ianaré sévi 719 Jan 05, 2023
Image2scan - a python program that can be applied on an image in order to get a scan of it back

image2scan Purpose image2scan is a python program that can be applied on an image in order to get a scan of it back. For this purpose, it searches for

Kushal Shingote 2 Feb 13, 2022
Random collage/montage generator with drop-shadow

Random Collage Example Usage These are the sample input files in $PWD for the below examples: 1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10

M B 1 Dec 07, 2021
GPU-accelerated image processing using cupy and CUDA

napari-cupy-image-processing GPU-accelerated image processing using cupy and CUDA This napari plugin was generated with Cookiecutter using with @napar

Robert Haase 16 Oct 26, 2022
Create a 2D mesh for an airfoil in GMSH using python.

GMSHFoil A simple class to create a 2D mesh for an airfoil in GMSH using python. Requirements pip install airfoils

Charilaos Mylonas 1 May 16, 2022
💯 Watermark your images with one line of command

Watermarker 💯 Watermark your images with one line of command 🧐 $ pip3 install

Orhan Emre Dikicigil 3 May 01, 2022
Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine.

img2dataset Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine. Also supports

Romain Beaumont 1.4k Jan 01, 2023
A python script for extracting/removing exif data from images by @AbirHasan2005

Image-Exif A Python script for extracting exif metadata from images. How to use? Using this script you can extract exif data from image and save in .c

Abir Hasan 13 Dec 16, 2022
Tools for making image cutouts from sets of TESS full frame images

Cutout tools for astronomical images Astrocut provides tools for making cutouts from sets of astronomical images with shared footprints. It is under a

Space Telescope Science Institute 20 Dec 16, 2022
Fixes 500+ mislabeled MURA images

In this repository, new csv files are provided that fixes 500+ mislabeled MURA x-rays for all categories. The mislabeled x-rays mainly had hardware in them. This project only fixes the false negative

Pieter Zeilstra 4 May 18, 2022
Glyphtracer is an app for converting images of letters to a font

Glyphtracer takes an image that contains pictures of several letters. It recognizes all them and lets the user tag each letter to a Unicode code point. It then converts the images to vector form and

Jussi Pakkanen 38 Dec 24, 2022
Image Processing - Make noise images clean

影像處理-影像降躁化(去躁化) (Image Processing - Make Noise Images Clean) 得力於電腦效能的大幅提升以及GPU的平行運算架構,讓我們能夠更快速且有效地訓練AI,並將AI技術應用於不同領域。本篇將帶給大家的是 「將深度學習應用於影像處理中的影像降躁化 」,

2 Aug 04, 2022
BeeRef — A Simple Reference Image Viewer

BeeRef — A Simple Reference Image Viewer BeeRef lets you quickly arrange your reference images and view them while you create. Its minimal interface i

Rebecca 245 Dec 25, 2022
Convert a DOS Punk image to text

DOS Punk Text Inspired by MAX CAPACITY's DOS Punks & the amazing DOS Punk community. DOS Punk Text is a Python 3 script that renders a DOS Punk image

4 Jan 13, 2022
㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.

python-barcode python-barcode provides a simple way to create barcodes in Python. There are no external dependencies when generating SVG files. Pillow

Hugo Barrera 419 Dec 26, 2022
A GUI-based (PyQt5) tool used to design 2D linkage mechanism.

Pyslvs-UI A GUI-based (PyQt5) tool used to design 2D linkage mechanism. Planar Linkages Simulation Python-Solvespace: Kernel from Solvespace with Cyth

Yuan Chang 141 Dec 13, 2022
Glyph-graph - A simple, yet versatile, package for graphing equations on a 2-dimensional text canvas

Glyth Graph Revision for 0.01 A simple, yet versatile, package for graphing equations on a 2-dimensional text canvas List of contents: Brief Introduct

Ivan 2 Oct 21, 2022