img2ansi

command module
v0.0.0-...-0917560 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 23 Imported by: 0

README

img2ansi

Renders raster images for a terminal using ANSI color codes. Supported image types are JPEG, PNG, and GIF (which may be animated).

img2ansi motd.png
img2ansi -animate -repeat=5 -scale https://i.imgur.com/872FDBm.gif
img2ansi -h

Image converter based on @saikobee's nifty tool

Install

go get github.com/bmatsuo/img2ansi

NOTE: Windows is not supported.

Documentation

On godoc.org

Unix friendly

img2ansi is built to work with streams and can operate on standard input. So, while it natively supports GET requests against HTTP URLs you can pipe data in from curl, netcat, or whatever else.

curl https://i.imgur.com/872FDBm.gif | img2ansi -animate -width=80 -repeat=5
netcat -lp 8000 | img2ansi -animate -width=80
Saving images

The output of img2ansi can be redirected to a file and replayed later using cat.

img2ansi -animate -width=80 -repeat=5 https://i.imgur.com/872FDBm.gif > awesome
cat awesome

Better yet, the output can be compressed using a program like gzip

img2ansi -animate -width=80 -repeat=5 https://i.imgur.com/872FDBm.gif | gzip > awesome.gz
gzip -dc awesome.gz

The size difference can be substantial for large images (like GIFs).

$ ls -lh awsome*
-rw-rw-r-- 1 bmatsuo bmatsuo 1.4M Jun 20 01:52 awesome
-rw-rw-r-- 1 bmatsuo bmatsuo 114K Jun 20 01:52 awesome.gz

Manipulating images

For simple manipulation and combination of images and text unix-friendly tools like those provided by ImageMagick can be piped directly into img2ansi.

convert -background transparent -fill red -pointsize 72 label:"blorp" gif:- | img2ansi -scale

Documentation

Overview

Command img2ansi renders raster images for a terminal using ANSI color codes. Supported image types are JPEG, PNG, and GIF (which may be animated).

img2ansi motd.png
img2ansi -animate -repeat=5 -scale https://i.imgur.com/872FDBm.gif
img2ansi -h

The command takes as arguments URLs referencing images to render. If no arguments are given img2ansi reads image data from standard input. Image URLs may be local files (simple paths or file:// urls) or HTTP(S) URLs.

Directories

Path Synopsis
Package gif implements a GIF image decoder and encoder.
Package gif implements a GIF image decoder and encoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL