terminal-image

Display images in the terminal

Github stars Tracking Chart

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));
})();

License

MIT © Sindre Sorhus

Main metrics

Overview
Name With Ownersindresorhus/terminal-image
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2018-05-08 16:14:22
Pushed At2025-01-03 22:00:03
Last Commit At
Release Count13
Last Release Namev3.1.1 (Posted on 2025-01-03 22:59:30)
First Release Namev0.1.0 (Posted on 2018-05-08 23:26:11)
用户参与
Stargazers Count1k
Watchers Count8
Fork Count27
Commits Count37
Has Issues Enabled
Issues Count27
Issue Open Count5
Pull Requests Count12
Pull Requests Open Count0
Pull Requests Close Count7
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private