npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@akirco/termimg

v0.1.0

Published

Terminal image preview library — Kitty, Sixel, HalfBlock, Braille, ASCII

Readme

termimg

终端图片预览库 — Kitty, Sixel, HalfBlock, Braille, ASCII

自动检测终端支持的协议,将图片渲染到终端中。支持 JPG、PNG、GIF、WebP、AVIF 等主流格式。

安装

npm install termimg
# or
bun add termimg

使用

基本用法

import { renderImage } from 'termimg'

const result = await renderImage('photo.jpg')
process.stdout.write(result.stream)

自动检测终端协议并输出渲染结果。

指定协议

const result = await renderImage('photo.jpg', { protocol: 'kitty' })
process.stdout.write(result.stream)

手动检测协议

import { detectProtocol } from 'termimg'

const proto = detectProtocol() // 'kitty' | 'sixel' | 'halfblock'

调整尺寸

// 缩放
await renderImage('photo.jpg', { scale: 0.5 })

// 固定宽度(字符列数)
await renderImage('photo.jpg', { cols: 80 })

// 固定高度(字符行数)
await renderImage('photo.jpg', { rows: 24 })

// 指定偏移
await renderImage('photo.jpg', { x: 10, y: 5 })

底层 API

import { loadImage, resizeImage, KittyEncoder } from 'termimg'

const img = await loadImage('photo.jpg')
const resized = await resizeImage(img, 400, 300)
const encoder = new KittyEncoder()
const output = encoder.encode(resized.width, resized.height, resized.data)
process.stdout.write(output)

清除图片

import { clearImage } from 'termimg'

const clear = await clearImage('kitty', { cols: 40, rows: 20 })
process.stdout.write(clear)

CLI

termimg photo.jpg
termimg photo.jpg --scale 0.5
termimg photo.jpg --cols 80
termimg photo.jpg --protocol kitty
termimg photo.jpg --protocol sixel --no-aspect

选项

| 选项 | 说明 | |------|------| | --scale <n> | 缩放比例(默认 1.0) | | --cols <n> | 固定宽度(字符列数) | | --rows <n> | 固定高度(字符行数) | | --protocol <p> | 强制协议:kitty, sixel, halfblock, braille, ascii, auto | | --x <n> | 水平偏移(字符单位) | | --y <n> | 垂直偏移(字符单位) | | --no-aspect | 不保持宽高比 |

终端兼容性

| 协议 | 终端 | |------|------| | Kitty | Kitty, Ghostty, Rio, Warp, WezTerm, iTerm2 (≥3.4), Konsole (≥22.04) | | Sixel | Foot, VS Code (≥1.80), Rio (≥12), WezTerm, Mintty, Konsole (≥22.04), mlterm | | HalfBlock | 通用回退方案 | | Braille | 通用回退方案 | | ASCII | 通用回退方案 |

License

AGPL-3.0-or-later