Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultASCIIPalette = "@%#*+=-:. "
DefaultASCIIPalette contains the default palette used for the ascii encoding
Source from http://paulbourke.net/dataformats/asciiart/
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image converts images to pseudo greyscale text reprosentation
func NewImage ¶
func NewImage() *Image
NewImage creates new ASCII image encoder using the default palette
func NewImageCustomPalette ¶
NewImageCustomPalette creates new ASCII image encoder using custom palette
func (Image) Encode ¶
Encode converts image to text and writes it to out
Example ¶
package main import ( "encoding/base64" "image" "os" "strings" _ "image/png" "github.com/aquilax/img2ascii/ascii" ) func getExampleImage() image.Image { reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(data)) i, _, _ := image.Decode(reader) return i } func main() { c := ascii.NewImage() i := getExampleImage() c.Encode(os.Stdout, i) } const data = ` iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAII0lEQVRo3pWaX6wdRR3HP7Nn799z z9k9GGiNt4KlD1UgNoZINWhsTEEk/PEBbLCIWEkI+qQm+KIvpDQxRZKKSmMJD5ooMdHCxRoVSCSg hjZizI2hhGoxXkmK3rN7e/7cc+89Oz7s7DmzuzOzp5tMdnd2zsz8fr/5/v4ewetSEgEx5O7Zcwy0 y9/rWxAyboFqoXYPC+96/xwDYK2wWOTYRGToA5+Q9BKGe/Zs+N6NgU2Q5Fvx0vtlrm+G+dHixUsY mqk/wqdlGWOaC8Abv3cjkJu2DbpbOm6KOqG2gOfYtJm7PoEcf7BtlkKfdvVikBvljWO4m54lUyw4 jwEOQsCHCIIAhGf+HdXS7MfAoMzlpEIyyeibr4gQE5xnUZAA7bS/GaTsFbgb5rn7Mcj1MpfRNmo/ SiDxaeQkMVlLJYBIl2mGIGpuDDgkui6g3TcfGWEANyUJ1WjSKp9Tx9FSBGjTNBQRrqNTxII3/jYA on75mEiLJMpY8WhOJAl0CRSmXAhA+HaNV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mtBYMdiBz1n4KUg3BcDxcVdXAM1jtNoNnsAFp0 n5jtRU1Cq1HQQm0LExKzcmgG+SosE8TqopS2aU9QCbBgxiMlwitKQE70FxOQ0FBVWK8C2J7FakcM 6Ftrc1SDUtPz/wfM8xARuOIpIgAAAABJRU5ErkJggg== `
Output: =++++***###%%%%%%%%%######****************###### ===+++***###%%%%%%%%%######****************##### -===+++***###%%%%%%%%%######****************#### --===+++***###%%%%%%%%%######****************### ---===+++***###%%%%%%%%%######****************## ----===+++***###%%%%%%%%%######****************# -----===+++***###%%%%%%%%%######**************** ------===+++***###%%%%%%%%%######*************** -------===+++***###%%%%%%%%%######************** ==------===+++***###%%%%%%%%%######************* ===------===+++***###%%%%%%%%%######************ ====------===+++***###%%%%%%%%%######*********** =====------===+++***###%%%%%%%%%######********** ======------===+++***###%%%%%%%%%######********* =======------===+++***###%%%%@%%%%######******** ========------===+++***###%%%@%%%%%######******* =========------===+++***###%%@%%%%%%######****** ===#@@===@@*--@#@*%@#+*@%@%#%@%%@@@%%######***** ===@*=====+@--@+=@*+@++@##@##@%%@@%@%%######**** ===*%%==#@@@--@--@==@++@**@##@%%@@@@%%@@#####*** =====%*=@++@=-@--@-=@=+@*#@**@##@@%%%%%%%#####** ===@@%==#@#@==@--@--@==@%@#**@##%@@@%%%%%%###### ===============------==@+++****###%%%%%%%%%##### -===============------=@=++++***###%%%%%%%%%#### --=*@@===@=======------====+++***###%%%%%%%%%### ---@==@==@========-------===+++***###%%%%%%%%%## ---@=====@=========-------===+++***###%%%%%%%%%# --@@@=@==@==+@@*====-=%@@--+@@*++@%@%@@@%%%%%%%% ---@--@==@==@*+@=====%*=---@**@++@##@%%@%%%%%%%% :--@--@==@==@@@@=====@=----@==@=+@+*@*#@#%%%%%%% ::-@--@-=@==@*=======%*=---%++@==@++@**@##%%%%%% :::@--@--@==+@@@==@==+%@@--+@@+==@++@**@###%%%%% ::::------===============-------===+++***###%%%% :::::------================------===+++***###%%% ::::::------================------===+++***###%% :::::::------================------===+++***###% ::::::::------================------===+++***### :::::::::------================------===+++***## -:::::::::-------===============------===+++***# --:::::::::------================------===+++*** ---:::::::::-------===============------===+++** =---:::::::::-------===============------===+++* ==---:::::::::-------===============------===+++ ===----:::::::::------===============------===++ +===----:::::::::------===============------===+ ++===----:::::::::------===============------=== +++====---:::::::::------===============------== *+++====---:::::::::------===============------=
func (Image) GetFontRatio ¶
GetFontRatio returns the font ratio
Click to show internal directories.
Click to hide internal directories.