pngtoansi

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2020 License: MIT Imports: 6 Imported by: 0

README

pngtoansi

Convert PNG image to ANSI art using UTF-8 characters.

For best results it is necessary to use a font compatible with characters "█", "▀", "▄", I recommend the source code pro fount.

Install

Install as a Utility
go install github.com/crgimenes/pngtoansi/cmd/pngtoansi 
Install as a Golang package
go get github.com/crgimenes/pngtoansi

Examples

Convert PNG to ANSI in the terminal
pngtoansi -f ./examples/gopher.png

Adjusted the background color. It is possible to change the color used to replace the transparent background using the -rgb parameter.

pngtoansi -f ./examples/test-01.png -rgb FFFFFF
Golang example
...
p := pngtoansi.New()
err = p.PrintFile("./examples/gopher.png", "FFFFFF")
if err != nil {
	fmt.Println(err)
	return
}

Contributing

  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Create a branch with your modifications git checkout -b fantastic-feature.
  • Then commit your changes git commit -m 'Implementation of new fantastic feature'
  • Make a push to your branch git push origin fantastic-feature.
  • Submit a Pull Request so that we can review your changes

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImgToANSI

type ImgToANSI struct {
	DefaultColor RGB
}

ImgToANSI holds module parameters

func New

func New() *ImgToANSI

New create a new instance of ImgToANSI

func (*ImgToANSI) Fprint

func (p *ImgToANSI) Fprint(w io.Writer, img image.Image) error

Fprint prints write a image to a writer using ANSI codes

func (*ImgToANSI) FprintFile

func (p *ImgToANSI) FprintFile(w io.Writer, fileName string, defaultRGB string) error

FprintFile write a file to the Stdout using ANSI codes

func (*ImgToANSI) Print

func (p *ImgToANSI) Print(img image.Image) error

Print prints a image in the stdout using ANSI codes

func (*ImgToANSI) PrintFile

func (p *ImgToANSI) PrintFile(fileName string, defaultRGB string) error

PrintFile print a png file to the stdout using ANSI codes

func (*ImgToANSI) SetRGB

func (p *ImgToANSI) SetRGB(rgb string) error

SetRGB update RGB values in current instance of ImgToANSI

type RGB

type RGB struct {
	R, G, B uint32
}

RGB color

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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