Skip to content

alan-ar1/imgfetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgfetch

Display pixel-perfect images in your terminal using Kitty's graphics protocol.

image

About

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.

Terminal Support

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.

Installation

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

Usage

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.

TODO

  • iTerm2 inline image protocol support
  • Image display modes (contain, cover, fill, etc.)
  • PDF image preview

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

MIT

About

Display pixel-perfect images in your terminal using Kitty's graphics protocol.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages