Skip to content
Display images in the terminal
Branch: master
Clone or download
Latest commit 69e0517 Apr 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Init May 8, 2018
.gitattributes Init May 8, 2018
.gitignore Init May 8, 2018
.npmrc Init May 8, 2018
.travis.yml Add TypeScript definition (#15) Apr 29, 2019
example.js Init May 8, 2018
fixture.jpg Init May 8, 2018
index.d.ts Add TypeScript definition (#15) Apr 29, 2019
index.js Add TypeScript definition (#15) Apr 29, 2019
index.test-d.ts Add TypeScript definition (#15) Apr 29, 2019
license Init May 8, 2018
package.json 0.2.0 Apr 29, 2019
readme.md Add tip to readme on how to display a remote image May 16, 2018
screenshot-iterm.jpg Init May 8, 2018
screenshot.png Init May 8, 2018
test.js Init May 8, 2018

readme.md

terminal-image Build Status

Display images in the terminal

Works in any terminal that supports colors.

In iTerm, the image will be displayed in full resolution, since iTerm has special image support.

Install

$ npm install terminal-image

Usage

const terminalImage = require('terminal-image');

(async () => {
	console.log(await terminalImage.file('unicorn.jpg'));
})();

API

Supports PNG and JPEG images.

terminalImage.buffer(imageBuffer)

Returns a Promise<string> with the ansi escape codes to display the image.

imageBuffer

Type: Buffer

Buffer with the image.

terminalImage.file(filePath)

Returns a Promise<string> with the ansi escape codes to display the image.

filePath

Type: string

File path to the image.

Tip

Display a remote image

const terminalImage = require('terminal-image');
const got = require('got');

(async () => {
	const {body} = await got('sindresorhus.com/unicorn', {encoding: null});
	console.log(await terminalImage.buffer(body));
})();

Related

License

MIT © Sindre Sorhus

You can’t perform that action at this time.