With this package can you display an image in your terminal.
The height of the generated image is customizable.
The supported image-types are png (.png), jpeg (.jpg, .jpeg, .jfif), singleframe gif (.gif) and webP (.webp).
To import the package use go get github.com/fabiokaelin/terminalimage
.
package main
import (
"fmt"
"github.com/fabiokaelin/terminalimage"
)
func main() {
imageString, err := terminalimage.ImageToString("img.png", 20, true)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(imageString)
}
To show the convertion, here is the original image:
The following are the converte ones:
64 pixel with pixelsplit on:
64 pixel with pixelsplit off:
20 pixel with pixelsplit on:
20 pixel with pixelsplit off: