Display pixel-perfect images in your terminal using Kitty's graphics protocol.
imgfetch is a Go package and a CLI tool for displaying images directly in terminal emulators that support Kitty's graphics protocol. Also be aware that it is primarily a fun side project that I may use as a package for other TUI projects or for my personal use.
Currently only supports terminals that implement Kitty's graphics protocol with tmux support. Other protocols like iTerm2's inline image protocol may be added in the future.
CLI:
go install github.com/alan-ar1/imgfetch/cmd/imgfetch@latest
If you are on an arch based distro, you can use an AUR helper:
yay -S imgfetch
PKG:
go get github.com/alan-ar1/imgfetch/pkg/imgfetch
CLI:
imgfetch path/to/image.png
You can also add an optional -i flag to see basic file info.
Note: Displaying thumbnails for video files are also supported if ffmpeg is installed. Additional file type support may be added in the future.
PKG:
// For local files
imgSeq, err := imgfetch.GetImageSeq("local_file_path")
if err != nil {
// handle error
}
fmt.Print(imgSeq)
// For remote files
remoteImgSeq, err := imgfetch.GetRemoteImageSeq(img) // param img of type image.Image
if err != nil {
// handle error
}
fmt.Print(imgSeq)Both GetImageSeq and GetRemoteImageSeq accept an optional second parameter to specify image dimensions:
size := imgfetch.ImageTermSize{Rows: 20, Columns: 40}
imgSeq, err := imgfetch.GetImageSeq("path/to/image.png", size)If not specified, images default to 1/4 of the terminal's column width.
- iTerm2 inline image protocol support
- Image display modes (contain, cover, fill, etc.)
- PDF image preview
Contributions are welcome! Feel free to open issues or submit pull requests.
MIT