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?
已存档?
是复刻?
已锁定?
是镜像?
是私有?