Giter VIP home page Giter VIP logo

pix2term's Introduction

Pixel to Terminal

Usage

$ python3 pix2term.py image.png

Since the output is text with special characters, you can generate an image once and display it later with cat:

$ python3 pix2term.py image.png > image_ansi
$ cat image_ansi

Requirements

This script depends on Python 3 and Pillow. Check Pillow’s documentation for detailed instructions, but as with any Python package, it boils down to pip install Pillow or using your distro’s package manager.

About

This is a script that shows an image in a 256-color terminal emulator using ANSI escape codes. Each pixel is represented as a pair of spaces with a specific background color, which tries to match the original pixel color as closely as possible. In other words, you can create an image of up to $((COLUMNS/2)) pixels without line wrapping. Note that a character in a terminal emulator may not have an aspect ratio of 2:1, which means images might appear slightly stretched.

Support

This script does not use the eight normal and eight bright colors from VT100 terminal emulators; instead, it uses the extended 216-color palette accessible via ESC[48;5;<n>m. The reason behind this is that many people change these colors to use a custom color scheme, many of which sacrifice color variety for aesthetic reasons. As far as I’m aware, most people only change the main 16 colors, making the extended ones “safer” for images.

To do

  • Support true color terminals or actual image dislay protocols.
  • Maybe add a better color matching algorithm.

Screenshots

./01.png./02.png
Art on Wikimedia CommonsArt on Wikimedia Commons by Kasuga

pix2term's People

Contributors

hlischt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.