img2ascii

package module
v0.0.0-...-4f0236f Latest Latest
Warning

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

Go to latest
Published: May 7, 2019 License: MIT Imports: 8 Imported by: 0

README

copied from https://github.com/stdupp/goasciiart, but made into library

example:

go get github.com/jackdoe/img2ascii


usage:

// from image object
img := image.Decode...
ascii := string(Img2Ascii(ScaleImage(img, 80)))

// or from file
ascii := string(MustFile2Ascii(os.Args[1], 80))


example: 

package main

import (
	"fmt"
	"os"

	"github.com/jackdoe/img2ascii"
)

func main() {
	ascii := string(img2ascii.MustFile2Ascii(os.Args[1], 80))
	fmt.Printf("%s", ascii)
}



go run examples/file.go example.jpg

example output:
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....~?7ZZZ7,..,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...~ZNMMMMM7...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...=DMMO8MMZ,...:,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,....,...,OMM+.IMMZ,...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,...........=NM$..=MMM$:....,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,.....:+7$:....+NMI...~OMMD7~....,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,....,+ZNMMZ,....:8MN,....~ZMMN7~....,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,....+8MMMMN=......INMZ......:$MMN7:...,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,...,7MM$:DMD~......,OMM,.,O7~..~OMMD+...,:,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,...IMM+..OMN=......,OMM:.=MMMZ,..7MMD=.........,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,.....,OM$...IMMZ,.....INMO..ZMMMM8...OMM$.....,:....,,,,,,,,,,,,,
,,,,,,,,,,,,........,OM=....DMMOI==?ZMMD,.:MMMMMM+..?MMZ,....$N$~....,,,,,,,,,,,
,,,,,,,,,,....:II....$M+....,OMMMMMMMN7,.,8MMMMMMI..?MM$.....?MMN7,...,,,,,,,,,,
,,,,,,,,,...,7NM7....+M8...~,.:+I7I+:...~DMMMMMMM+..ZMD=.....:8MMMO~...,,,,,,,,,
,,,,,,,,...:ZMMN+....,ZM$..DM8$+:,...:+$MMMMMMMMM:.:MN?.......$MMNM8~...,,,,,,,,
,,,,,,,...,$MNMN+.....+NM$.ZMMMMMMMMMMMMMMMMMMMMD..ZM8:.......IMM~7MZ,...,,,,,,,
,,,,,,,...+MM~NM7.....?NMO.IMMMMMMMM87==?78MMMMMZ.,NMD~......,ZMN..8M+...,,,,,,,
,,,,,,,...$MZ.8MN$~,,+8MN:.+MMMMMO+,.......,?8MMO..DMMO~....~$MM?..~M$...,,,,,,,
,,,,,,,..,OM7.:DMMMNNMMD~..?MMNI:.............+NM:.=NMMNO$$OMMN?....MO,..,,,,,,,
,,,,,,,..,ZMO..,I8NNNO?...~NMZ,................,88,.,?ZDNMMDO?,....:MO,..,,,,,,,
,,,,,,,...7MM:....,,,.,~?OMMO....................ND+...............ZM7...,,,,,,,
,,,,,,:...~8M8....:8MMMMMMMM~................,...7MMNZ?~..........$MD~...:,,,,,,
,,,,,,,,...=8M8:...~DMMMMMMN....Z:..........:O...?MMMMMMN+......=DMN?...,,,,,,,,
,,,,,,,,,...:7NM7:..,OMMMMM8...,MI..........7M...~MMMMMM?.....+8MMO=...,,,,,,,,,
,,,,,,,,,,....=OMMO:..ZMMMM$...?MD..........NM,..:MMMMD:...,?DMN$+,...,,,,,,,,,,
,,,,,,,,,,,,...,7MM8..:MMMMI...8MM=........?MM~..,NMMN:..,7NMO?:.....,,,,,,,,,,,
,,,,,,,,,,,,,...:8MN..,NMMM?..,MMMO........DMM+...DMMI...DMO~.....,,,,,,,,,,,,,,
,,,,,,,,,,,.,,..,ZMM,..NMMM?..~MMMM:......+MMMI...DMM:..~M8~...,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...$MM~..DMMM?..:MMMMI......8MMM$...DMM,..?MO,..,:,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...7MM=..8MMM+...=ZNMM,....+MN87~...DMD...$M$...,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...?MM?..8MMM$.....,+7:....==,......DM8...DMI...,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...+NMI..8MMMMZ=..................,+MMZ..,MM?...,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...=NM$..ZMMMMMM$...............,ZNMMMI..=MD=...:,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...~DMZ..=MMMMMMD...............7MMMMN:..7M8:...,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,...:8MD...=OMMMM$..........+....?MMMZ:...DMO,..,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,..,8MMZ:...:I8M7....~?...,M:..:7DI:...:8MM7...,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,...=$DMMZ=....~?I?=:DZ...,M$I7I=...:?OMMOI,...:,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,....:?OMMN$=....:=+7I:,:~I+:...=$DMMN$=,....,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,.....:+ZNMNZ?:...........:?OMMMN$+,.....,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,......,~IONMNOI=:,,:+$DMMMD$+,.....,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,......,=78MMMMMMMMDZ?~,.....,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,.......:+7ZZ$?~,......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,



Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASCIISTR = "MND8OZ$7I?+=~:,.."

Functions

func File2Ascii

func File2Ascii(fpath string, width int) ([]byte, error)

func Img2Ascii

func Img2Ascii(img image.Image, w, h int) []byte

func MustFile2Ascii

func MustFile2Ascii(fpath string, width int) []byte

func ScaleImage

func ScaleImage(img image.Image, w int) (image.Image, int, int)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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