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
Generate meme GIFs in which an image you choose can be viewed by the user only after they wait a whole hour.

Generate meme GIFs in which an image you choose can be viewed by the user only after they wait a whole hour.

Feliks Maak 1 Jan 31, 2022
Typesheet is a tiny Python script for creating transparent PNG spritesheets from TrueType (.ttf) fonts.

typesheet typesheet is a tiny Python script for creating transparent PNG spritesheets from TrueType (.ttf) fonts. I made it because I couldn't find an

Grayson Chao 12 Dec 23, 2022
PyLibTiff - a wrapper to the libtiff library to Python using ctypes

PyLibTiff is a package that provides: a wrapper to the libtiff library to Python using ctypes. a pure Python module for reading and writing TIFF and L

Pearu Peterson 105 Dec 21, 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
Bringing vtk.js into Dash and Python

Dash VTK Dash VTK lets you integrate the vtk.js visualization pipeline directly into your Dash app. It is powered by react-vtk-js. Docs Demo Explorer

Plotly 88 Nov 29, 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
Craft PNG files that appear completely different in Apple software

Ambiguous PNG Packer Craft PNG files that appear completely different in Apple software

David Buchanan 1k Dec 29, 2022
An application that maps an image of a LaTeX math equation to LaTeX code.

Convert images of LaTex math equations into LaTex code.

1.3k Jan 06, 2023
PyPixelArt - A keyboard-centered pixel editor

PyPixelArt - A keyboard-centered pixel editor The idea behind PyPixelArt is uniting: a cmdpxl inspired pixel image editor applied to pixel art. vim 's

Douglas 18 Nov 14, 2022
Python-fu-cartoonify - GIMP plug-in to turn a photo into a cartoon.

python-fu-cartoonify GIMP plug-in to turn a photo into a cartoon. Preview Installation Copy python-fu-cartoonify.py into the plug-in folder listed und

Pascal Reitermann 6 Aug 05, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major bi

CISiP Lab 39 Nov 25, 2022
Py3D - A 3d rendering engine written entirely in python

Py3D is a 3d rendering engine written entirely in python. It is a simple and eas

1up Community 2 Nov 14, 2022
Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

1 Jan 16, 2022
image-processing exercises.

image_processing Assignment 21 Checkered Board Create a chess table using numpy and opencv. view: Color Correction Reverse black and white colors with

Benyamin Zojaji 25 Dec 15, 2022
Depix is a tool for recovering passwords from pixelized screenshots.

This implementation works on pixelized images that were created with a linear box filter. In this article I cover background information on pixelization and similar research.

23.1k Jan 04, 2023
Simple utility to tinker with OPlus images

OPlus image utilities Prerequisites Linux running kernel 5.4 or up (check with uname -r) Image rebuilding Used to rebuild read-only erofs images into

Wiley Lau 15 Dec 28, 2022
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

David Dowd 108 Dec 19, 2022
Black-white image converter - Black-white photo colorization

Black-white image converter - Black-white photo colorization

1 Jan 02, 2022
display: a browser-based graphics server

display: a browser-based graphics server Installation Quick Start Usage Development A very lightweight display server for Torch. Best used as a remote

Szymon Jakubczak 205 Oct 17, 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 06, 2022