Skip to content

belfner/imcat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imcat

Preview any size image in a terminal window.

imcat tiger

Platform

Supports Linux, MacOS and Microsoft Windows 10 terminals.

Introduction

Do you ever find yourself logged into a server, over SSH, but there is no X11 connection. And you want to see the contents of an image?

imcat to the rescue!

imcat is a 24-bit image viewer that uses ANSI terminal colours to display any image supported by STB. It automatically resizes to the width of your terminal, using proper sampling kernels.

imcat also works on the latest version of Windows 10.

Usage

$ imcat [options] file1 [file2 .. fileN]

By default imcat fits the image to the console size while keeping its aspect ratio.

Use -h {NUM} and -w {NUM} to set the height or width of the output image respectively. If only one of the two is passed the image will maintain its aspect ratio.

$ imcat -w 10 {IMG_PATH}

Pass -h or -w on their own, with no number, to fit the image to that axis. -f or --fit fits to both axes and is the default.

$ imcat -h {IMG_PATH}

If you want to blend the image with the terminal background, then you need to specify the background color of your terminal. For instance:

$ export IMCATBG="#dad9cc"

If your shell prompt occupies lines below the image, set IMCATPROMPTH to the number of prompt lines so a fitted image is sized to leave room for it and stays fully on screen. The --prompt {NUM} flag overrides this value.

$ export IMCATPROMPTH=2
$ imcat {IMG_PATH}

Image formats

imcat decodes PNG, JPEG, GIF, BMP, PSD, TGA, HDR, PIC and PNM directly. For any other file, when ImageMagick (magick or convert) or FFmpeg is installed, imcat pipes the file through the first one it finds and displays the converted result.

Todo

  • Handle alpha-transparency. Requires reading the terminal background colour, somehow. Tricky.

Done

  • Correct for aspect ratio of terminal font.

Building

Unix

On Linux, just use 'make' to build the imcat binary.

Windows 10

On Windows, you need clang.exe from Visual Studio 2017 to build the imcat.exe binary. It's actually quite hard to get that compiler working, so you may just as well grab the pre-built imcat.exe binary.

License

Authors

Bram Stolk.

stb_image.h is by Sean Barrett et al.

Acknowledgements

A shout out to Frogtoss for the idea and help. Thanks!

Gallery

Sample use

About

Show any image in a terminal window.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 98.8%
  • Other 1.2%