Display images in iTerm
You probably want the higher-level terminal-image
package for displaying your images.
Even animated gifs!
Currently only supported on iTerm >=3.
npm install term-img
import terminalImage from 'term-img';
function fallback() {
// Return something else when not supported
}
console.log(terminalImage('unicorn.jpg', {fallback}));
Get the image as a string
that you can log manually.
Type: string | Uint8Array
File path to an image or an image as a buffer.
Type: object
Type: 'auto' | string | number
The width and height are given as a number followed by a unit, or the word 'auto'
.
N
: N character cells.Npx
: N pixels.N%
: N percent of the session's width or height.auto
: The image's inherent size will be used to determine an appropriate dimension.
Type: boolean
Default: true
Type: Function
Default: () => throw new UnsupportedTerminalError()
Enables you to do something else when the terminal doesn't support images.
- term-img-cli - CLI for this module
- term-kitty-img - Similar package but for Kitty, Konsole, WezTerm