term-img
Display images in terminals using the iTerm inline image protocol
Last updated 6 months ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install term-img 
SYNC missed versions from official npm registry.

term-img

Display images in terminals using the iTerm inline image protocol

You probably want the higher-level terminal-image package for displaying your images.

Even animated gifs!

Currently only supported on iTerm >=3, WezTerm, Konsole, Rio, and VSCode integrated terminal.

Install

npm install term-img

Usage

import terminalImage from 'term-img';

function fallback() {
	// Return something else when not supported
}

console.log(terminalImage('unicorn.jpg', {fallback}));

API

terminalImage(image, options?)

Get the image as a string that you can log manually.

image

Type: string | Uint8Array

File path to an image or an image as a buffer.

options

Type: object

width
height

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.
preserveAspectRatio

Type: boolean
Default: true

fallback

Type: Function
Default: () => throw new UnsupportedTerminalError()

Enables you to do something else when the terminal doesn't support images.

Related

Current Tags

  • 7.1.0                                ...           latest (6 months ago)

14 Versions

  • 7.1.0                                ...           6 months ago
  • 7.0.0                                ...           2 years ago
  • 6.0.0                                ...           5 years ago
  • 5.0.0                                ...           6 years ago
  • 4.1.0                                ...           7 years ago
  • 4.0.0                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 2.1.0                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (2)
Dev Dependencies (4)

Copyright 2013 - present © cnpmjs.org | Home |