Giter Club home page Giter Club logo

ansi_image's Introduction

ansi_image

A Rust utility to print an image as an ANSI string in the console. Supports UTF-8 characters.

By default, the image will take up the vertical space in the console but a size can be specified. The image can be rendered in characters if desired.

Operation

Run ansi_image with the name of an image file to print it to the console: ./ansi-image mona_lisa.jpg

Run with --help to get a list of parameters:

Usage: ansi_image [OPTION] [IMAGE FILE]

Options:
        --help          How to use this program.
    -v, --verbose       Verbose output
    -r                  Background reverse
    -b                  Blink
    -x NUMBER           Output width, in characters.
    -y NUMBER           Output height, in characters.
    -c CHARACTER        Character
        --font-width    Font width, in pixels
        --font-height   Font height, in pixels

-c Character

By default the image is rendered using spaces, but a character can be used instead with the -c parameter.

./ansi_image -c `#` monal_lisa.jpg

-r Reverse

This flag is useful with the -c flag. It renders the given character in the foreground colour, and the image with the background colour.

./ansi_image -c -r `#` monal_lisa.jpg

-x -y Output Size

By default, the image will take up the vertical space in the console. The size of the output, in charactes, can be given by the -x and -y parameters. The image aspect ratio will be maintained.

./ansi_image -y 14 mona_lisa.jpg

--font-width --font-height

By default, the utility assumes the console characters are 8x16 pixels. If the console's font dimensions are different, the size can be set with --font-width and --font-height.

Being able to explicitly set the font size is also useful fro rendering non-ASCII UTF-8 characters, which may be wider.

./ansi_image -c ๅ–œ --font-width 12 mona_lisa.jpg

-v Verbose

Prints information about the image and how it is being processed.

-b Blink

The blink option is included purely out of spite towards the W3C and their rejection of the <blink> tag.

Caveats

  • Only tested on a handful of images. It uses the excellent Rust Image crate to get the pixel colours, so should work with common image formats.
  • Console is not tested for ANSI capability.
  • Not tested on a Mac.
  • Very large images are slow to render.
  • No, animated GIFs don't work.

ansi_image's People

Contributors

paulmcgovern avatar fmotalleb 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.