Go version of image cat (or imgcat) with bmp, riff,tiff, vp8, vp8l, webp and (optional) HEIF image support (on top of standard Go images formats gif, jpg, png) and URL support and fallback to ASCII art.
PrintImageFile and PrintImageURL will print the image to the terminal, trying to figure out which terminal you are using and fallback to ASCII art if the terminal does not support images.
go install github.com/hilli/icat/cmd/icat@latest
# With HEIF support:
go install -tags heif github.com/hilli/icat/cmd/icat@latestNote: To enable heif support, you need to have libheif installed on your system. On macOS, you can install it via Homebrew:
brew install libheifOn Ubuntu, you can install it via apt:
sudo apt install libheif-devbut you will also probably need to downgrade the version used in icat before compilation. Ie installing libheif on Ubuntu 24.10 will [currently] give you version 1.18.1:
go get github.com/strukturag/libheif@v1.18.1and then you can install icat with heif support:
go install --tags=heif cmd/icat/icat.go
ls -l $(go env GOPATH)/bin/icatlibheif should be available on most package managers.
Alternatively, you can download the binary from the releases page or install via Homebrew:
brew install hilli/tap/icatwhich unfortunately does not support the heif files (Cross compilation is hard with C extensions, mkay).
icat image.jpg
# Or
icat https://example.com/image.pngpackage main
import (
"fmt"
"os"
"github.com/hilli/icat"
)
func main() {
err := icat.PrintImageFile("image.jpg")
if err != nil {
fmt.Println(err)
}
}