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
Python Digital Art Generator

Python Digital Art Generator The main goal of this repository is to generate all possible layers permutations given by the user in order to get unique

David Cuentas Mar 3 Mar 12, 2022
A tool for hiding data inside of images

Stegenography-tool a tool for hiding data inside of images Quick test: do python steg-encode.py test/message.txt test/covid19.png to generate the test

luke 2 Nov 02, 2021
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 2022
Tool that takes your photo and generates a pixelated color by number photo.

Color by number Tool that takes your photo and generates a pixelated color by number photo. Requirements You need to have python installed on your com

1 Dec 18, 2021
Tool to create a Phunk image with a custom background

Create Phunk image Tool to create a Phunk image with a custom background Installation Clone the repo git clone https://github.com/albanow/etherscan_sa

Albano Pena Torres 6 Mar 31, 2022
SALaD (Semi-Automatic Landslide Detection) is a landslide mapping system

SALaD (Semi-Automatic Landslide Detection) is a landslide mapping system. SALaD utilizes Object-based Image Analysis and Random Forest to map landslides.

NASA 14 Jan 04, 2023
GTK and Python based, simple multiple image editor tool

System Monitoring Center GTK3 and Python3 based, simple multiple image editor tool. Note: Development of this application is not completed yet. The ap

Hakan Dündar 1 Feb 02, 2022
thumbor is an open-source photo thumbnail service by globo.com

Survey If you use thumbor, please take 1 minute and answer this survey? It's only 2 questions and one is multiple choice!!! thumbor is a smart imaging

Thumbor (by @globocom) 9.3k Dec 31, 2022
Graphical tool to make photo collage posters

PhotoCollage Graphical tool to make photo collage posters PhotoCollage allows you to create photo collage posters. It assembles the input photographs

Adrien Vergé 350 Jan 02, 2023
A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos.

font2png A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos. To use from command line it expects python3 to be at /

Rich Elmes 3 Dec 22, 2021
Image generation API.

Image Generator API This is an api im working on Currently its just a test project Im trying to make custom readme images with your discord account pr

Siddhesh Zantye 2 Feb 19, 2022
A procedural Blender pipeline for photorealistic training image generation

BlenderProc2 A procedural Blender pipeline for photorealistic rendering. Documentation | Tutorials | Examples | ArXiv paper | Workshop paper Features

DLR-RM 1.8k Jan 02, 2023
Convert bitmap images to seeds for Tiny-83 NFT project.

What is this? This tool allows you to convert any 14p high and 22p wide Bitmap (.bmp) to the seed needed for the Tiny-83 NFT project. Project Twitter:

shib_maximalist 1 Oct 31, 2021
The ctypes-based simple ImageMagick binding for Python

Wand Wand is a ctypes-based simple ImageMagick binding for Python, supporting 2.7, 3.3+, and PyPy. All functionalities of MagickWand API are implement

Eric McConville 1.2k Dec 30, 2022
Img-to-ascii-art - Converter of image to ascii art

img-to-ascii-art Converter of image to ascii art Latest Features. Intoducing Col

1 Dec 31, 2021
A simple plugin to view APR images in napari

napari-apr-viewer A simple plugin to view APR images in napari This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-

5 Jan 24, 2022
Fix datetime EXIF data in photos downloaded from Google Takeout

fix-google-takeout Warning Use at your own risk. Backup your photos. Overview Google takeout for photos

Mayank Mandava 20 Nov 05, 2022
A simple Streamlit Component to compare images in Streamlit apps. It integrates Knightlab's JuxtaposeJS

streamlit-image-juxtapose A simple Streamlit Component to compare images in Streamlit apps using Knightlab's JuxtaposeJS. The images are saved to the

Robin 30 Dec 31, 2022
Sample data for the napari image viewer.

napari-demo-data Sample data for the napari image viewer. This napari plugin was generated with Cookiecutter using @napari's cookiecutter-napari-plugi

Genevieve Buckley 1 Nov 08, 2021
A Icon Maker GUI Made - Convert your image into icon ( .ico format ).

Icon-Maker-GUI A Icon Maker GUI Made Using Python 3.9.0 . It will take any image and convert it to ICO file, for web site favicon or Windows applicati

Insanecodes 12 Dec 15, 2021