Socket
Socket
Sign inDemoInstall

term-img

Package Overview
Dependencies
24
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    term-img

Display images in iTerm


Version published
Weekly downloads
121K
decreased by-17.02%
Maintainers
1
Install size
1.13 MB
Created
Weekly downloads
 

Readme

Source

term-img

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.

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 | Buffer

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.

Keywords

FAQs

Last updated on 03 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc