terminal-image

Display images in the terminal

Github星跟蹤圖

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

主要指標

概覽
名稱與所有者sindresorhus/terminal-image
主編程語言JavaScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2018-05-08 16:14:22
推送於2025-01-03 22:00:03
最后一次提交
發布數13
最新版本名稱v3.1.1 (發布於 2025-01-03 22:59:30)
第一版名稱v0.1.0 (發布於 2018-05-08 23:26:11)
用户参与
星數1k
關注者數8
派生數27
提交數37
已啟用問題?
問題數27
打開的問題數5
拉請求數12
打開的拉請求數0
關閉的拉請求數7
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?