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
Simple Python package to convert an image into a quantized image using a customizable palette

Simple Python package to convert an image into a quantized image using a customizable palette. Resulting image can be displayed by ePaper displays such as Waveshare displays.

Luis Obis 3 Apr 13, 2022
A simple programme for converting url into a qr code (.png file)

QrTk A simple lightweight programme for converting url into a qr code (.png file) Pre-Requisites Before installing the programme , you need to run the

Juss Patel 4 Nov 08, 2021
An open source image editor which can manipulate an image in many ways!

Image Editor - An open source image editor which can manipulate an image in many ways! If you need any more modes in repo or I

TroJanzHEX 44 Nov 17, 2022
reversable image censoring tool

StupidCensor a REVERSABLE image censoring tool to reversably mosiac censor jpeg files to temporarily remove image details not allowed on most websites

2 Jan 28, 2022
Console images in 48 colors, 216 colors and full rgb

console_images Console images in 48 colors, 216 colors and full rgb Full RGB 216 colors 48 colors If it does not work maybe you should change color_fu

Урядов Алексей 5 Oct 11, 2022
A simple image-level annotation tool supporting multi-channel images for napari.

napari-labelimg4classification A simple image-level annotation tool supporting multi-channel images for napari. This napari plugin was generated with

4 May 16, 2022
Panel Competition Image Generator

Panel Competition Image Generator This project was build by a member of the NFH community and is open for everyone who wants to try it. Relevant links

Juliano Mendieta 1 Oct 22, 2021
🛹 Turn an SVG into an STL for stencil creation purposes

svg2stl This repository provides a script which takes as input an SVG such as this one: It outputs an STL file like this one: You can also see an inte

Max Halford 3 Dec 29, 2021
Python framework for creating and scaling up production of vector graphics assets.

Board Game Factory Contributors are welcome here! See the end of readme. This is a vector-graphics framework intended for creating and scaling up prod

Adam Volný 5 Jul 13, 2022
This script is for photographers to do timeslice with one click.

One Click TimeSlice Tool What is this for This is for photographers who want to create TimeSlice pictures without installing PS plugins. Before using

Xi Zhao 13 Sep 23, 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
LabelMe annotation tool source code

LabelMe annotation tool source code Here you will find the source code to install the LabelMe annotation tool on your server. LabelMe is an annotation

MIT CSAIL Computer Vision 1.3k Jan 03, 2023
👷 Build images with images

👷 Build images with images. About Tiler is a tool to create an image using all kinds of other smaller images (tiles). It is different from other mosa

5.5k Jan 03, 2023
A Blender add-on to create interesting meshes using symmetry

Procedural Symmetries This Blender add-on automates the process of iteratively applying a set of reflection planes to a base mesh. The result will con

1 Dec 29, 2021
Forza painter app with python

forza-painter Discord: A-Dawg#0001 (AE) Supports: Forza Horizon 5 Offically (OTHER v1.405.2.0, MS STORE v3.414.967.0, STEAM v1.414.967.0) Unofficially

320 Dec 31, 2022
Convert HDR photos taken by iPhone 12 (or later) to regular HDR images

heif-hdrgainmap-decode Convert HDR photos taken by iPhone 12 (or later) to regular HDR images. Installation First, make sure you have the following pa

Star Brilliant 5 Nov 13, 2022
The coolest python qrcode maker for small businesses.

QR.ify The coolest python qrcode maker for small businesses. Author Zach Yusuf Project description Python final project. Built to test python skills P

zachystuff 2 Jan 14, 2022
With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen

Oraxen-item-to-yml With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen How to use Install the

Akex 1 Dec 29, 2021
Unique image & metadata generation using weighted layer collections.

nft-generator-py nft-generator-py is a python based NFT generator which programatically generates unique images using weighted layer files. The progra

Jonathan Becker 243 Dec 31, 2022
PyGram Instagram-like image filters.

PyGram Instagram-like image filters. Usage First, import the client: from filters import * Instanciate a filter and apply it: f = Nashville("image.jp

Ajay Kumar Nagaraj 102 Feb 21, 2022