Convert image to ASCII
go get https://github.com/qeesung/image2ascii
package main
import (
"fmt"
"github.com/qeesung/image2asicc/convert"
"image"
_ "image/jpeg"
_ "image/png"
"log"
"os"
)
func main() {
f, err := os.Open("example/images/lufei.jpg")
if err != nil {
log.Fatal(err)
}
img, _, err := image.Decode(f)
if err != nil {
log.Fatal(err)
}
f.Close()
asciiImage := convert.Image2ASCIIString(img, &convert.Options{
Ratio: 0.2,
})
fmt.Print(asciiImage)
}
output
Raw Image | ASCII Image |
---|---|