aimg

package module
v0.0.0-...-8966abf Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2016 License: ISC Imports: 10 Imported by: 0

README

aimg

GoDoc

A package to convert images to ANSI color coded text. aimg uses unicode UPPER HALF BLOCK to archieve twice the pixels (tm) per character.

Usage

As a package: see GoDoc

As a command:

> aimg -h
Usage: aimg [-w (num | num% | .num) ] file [file...]
  -w, --width="100%": Output width. Supports column count, percentage and decimals.

screenshot

Get the cli tool

> go get github.com/stroborobo/aimg/cmd/aimg

That's it :)


Inspired by minikomi's ansipix.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Top    *ansirgb.Color
	Bottom *ansirgb.Color
	// contains filtered or unexported fields
}

Block represents two pixels or a character in a string. It contains a Unicode LOWER/UPPER HALF BLOCK, so the top or bottom "pixel" is the foreground color and the other one is the background color. The character used might change if transparency is needed, which is only possible by using the default background color.

func (*Block) String

func (b *Block) String() string

String returns the string representation of the block. If aimg can't determine whether this is a UTF-8 environment, String will use a '#' instead of the LOWER/UPPER HALF BLOCK. If the block's color is equal to the one before, it'll just return a string containing a single space.

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image represents an ANSI color code "image"

func NewImage

func NewImage(cols int) *Image

NewImage returns an Image that will parse and print for a given width of columns.

func (*Image) ActualSize

func (im *Image) ActualSize() (height, width int)

ActualSize returns the size of the underlying image.

func (*Image) Blank

func (im *Image) Blank() string

Blank returns a string containing as many newlines as needed to display the image.

func (*Image) BlankReset

func (im *Image) BlankReset() string

BlankReset returns a string like Blank() but with an escape code to set the cursor to the first of the previous newlines.

func (*Image) ParseFile

func (im *Image) ParseFile(fpath string) error

ParseFile is a shorthand for os.Open() and ParseReader().

func (*Image) ParseReader

func (im *Image) ParseReader(rd io.Reader) error

ParseReader reads image data from the reader.

func (*Image) Size

func (im *Image) Size() (rows, cols int)

Size returns the resulting size in columns and rows.

func (*Image) String

func (im *Image) String() string

String returns the Image's string representation. It's a shorthand to WriteTo() using a bytes.Buffer and buf.String().

func (*Image) WriteTo

func (im *Image) WriteTo(wr io.Writer) (int, error)

WriteTo writes the image data to wr.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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