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
Generative Art Synthesizer - a python program that generates python programs that generates generative art

GAS - Generative Art Synthesizer Generative Art Synthesizer - a python program that generates python programs that generates generative art. Examples

Alexey Borsky 43 Dec 3, 2022
Ascify-Art - An easy to use, GUI based and user-friendly colored ASCII art generator from images!

Ascify-Art This is a python based colored ASCII art generator for free! How to Install? You can download and use the python version if you want, modul

Akash Bora 14 Dec 31, 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

null 1 Dec 31, 2021
Generate waves art for an image

waves-art Generate waves art for an image. Requirements: OpenCV Numpy Example Usage python waves_art.py --image_path tests/test1.jpg --patch_size 15 T

Hamza Rawal 18 Apr 4, 2022
Computer art based on joining transparent images

Computer Art There is no must in art because art is free. Introduction The following tutorial exaplains how to generate computer art based on a series

Computer Art 12 Jul 30, 2022
Art directed cropping, useful for responsive images

Art direction sets a focal point and can be used when you need multiple copies of the same Image but also in in different proportions.

Daniel 1 Aug 16, 2022
HTML2Image is a lightweight Python package that acts as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

null 176 Jan 1, 2023
Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like

Python Image Morpher (PIM) is a program that can take two images and blend them to whatever extent or precision that you like! It is designed to emulate some of Python's OpenCV image processing from scratch without reference.

David Dowd 108 Dec 19, 2022
MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images

MetaStalk About MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images, which are tested. More forma

Cyb3r Jak3 1 Jul 5, 2021
missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.

Missing Pixel Filler This is the official code repository for the Missing Pixel Filler by SpaceML. missing-pixel-filler is a python package that, give

SpaceML 11 Jul 19, 2022
Program for analyzing shadows from Cassini images

Moons: An Analysis Module for Vicar Files General This packages/program was created for my bachelor's thesis for the Astronomy department at Universit

Joni 1 Jul 16, 2021
The following program is used to swap the faces from two images.

Face-Swapping The following program is used to swap the faces from two images. In today's world deep fake technology has become really popular . As a

null 1 Jan 19, 2022
Using P5.js, Processing and Python to create generative art

Experiments in Generative Art Using Python, Processing, and P5.js Quick Links Daily Sketches March 2021. | Gallery | Repo | Done using P5.js Genuary 2

Ram Narasimhan 33 Jul 6, 2022
vsketch is a Python generative art toolkit for plotters

Generative plotter art environment for Python

Antoine Beyeler 380 Dec 29, 2022
Samila is a generative art generator written in Python

Samila is a generative art generator written in Python, Samila let's you create arts based on many thousand points. The position of every single point is calculated by a formula, which has random parameters. Because of the random numbers, every image looks different.

Sepand Haghighi 947 Dec 30, 2022
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
👾 Python project to help you convert any image into a pixel art.

?? Pixel Art Generator Python project to help you convert any image into a pixel art. ⚙️ Developer's Guide Things you need to get started with this co

Atul Anand 6 Dec 14, 2022
An ascii art generator that's actually good. Does edge detection and selects the most appropriate characters.

Ascii Artist An ascii art generator that's actually good. Does edge detection and selects the most appropriate characters. Installing Installing with

null 18 Jan 3, 2023
Computer art based on quadtrees.

Quads Computer art based on quadtrees. The program targets an input image. The input image is split into four quadrants. Each quadrant is assigned an

Michael Fogleman 1.1k Dec 23, 2022