Logo

0x3d.Site

is designed for aggregating information.
Welcome
check repository here

terminal-image

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

import terminalImage from 'terminal-image';

console.log(await terminalImage.file('unicorn.jpg'));

Optionally, you can specify the height and/or width to scale the image. That can be either the percentage of the terminal window or number of rows and/or columns. Please note that the image will always be scaled to fit the size of the terminal. If width and height are not defined, by default the image will take the width and height of the terminal.

It is recommended to use the percentage option.

import terminalImage from 'terminal-image';

console.log(await terminalImage.file('unicorn.jpg', {width: '50%', height: '50%'}));

You can set width and/or height as columns and/or rows of the terminal window as well.

import terminalImage from 'terminal-image';

console.log(await terminalImage.file('unicorn.jpg', {width: 50}));

By default, aspect ratio is always maintained. If you don't want to maintain aspect ratio, set preserveAspectRatio to false. However, your image will be scaled to fit the size of the terminal.

import terminalImage from 'terminal-image';

console.log(await terminalImage.file('unicorn.jpg', {width: 70, height: 50, preserveAspectRatio: false}));

API

Supports PNG and JPEG images. Animated GIFs are also supported with .gifBuffer and .gifFile.

terminalImage.buffer(imageBuffer, options?)

terminalImage.file(filePath, options?)

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

terminalImage.gifBuffer(imageBuffer, options?)

terminalImage.gifFile(filePath, options?)

Returns a function that can be called to stop the GIF animation.

options

Type: object

height

Type: string | number

Custom image height.

Can be set as percentage or number of rows of the terminal. It is recommended to use the percentage options.

width

Type: string | number

Custom image width.

Can be set as percentage or number of columns of the terminal. It is recommended to use the percentage options.

preserveAspectRatio

Type: boolean
Default: true

Whether to maintain image aspect ratio or not.

maximumFrameRate

Only works for terminalImage.gifBuffer or terminalImage.gifFile

Type: number
Default: 30

Maximum framerate to render the GIF. This option is ignored when using iTerm.

renderFrame

Only works for terminalImage.gifBuffer or terminalImage.gifFile

Type: (text: string) => void
Default: log-update

Custom handler which is run for each frame of the GIF.

This can be set to change how each frame is shown.

renderFrame.done

Only works for terminalImage.gifBuffer or terminalImage.gifFile

Type: () => void
Default: log-update

Custom handler which is run when the animation playback is stopped.

This can be set to perform a cleanup when playback has finished.

Tip

Display a remote image

import terminalImage from 'terminal-image';
import got from 'got';

const body = await got('https://sindresorhus.com/unicorn').buffer();
console.log(await terminalImage.buffer(body));

Related

Node.js
Node.js
Node.js is a runtime environment for executing JavaScript on the server side. Known for its non-blocking architecture, it’s ideal for building fast and scalable network applications, including APIs and real-time services.
GitHub - davglass/license-checker: Check NPM package licenses
GitHub - davglass/license-checker: Check NPM package licenses
Build software better, together
Build software better, together
CodeSandbox
CodeSandbox
Node.js Design Patterns Third Edition by Mario Casciaro and Luciano Mammino
Node.js Design Patterns Third Edition by Mario Casciaro and Luciano Mammino
GitHub - almost/through2-concurrent: Simple Node.JS stream (streams2) Transform that runs the transform functions concurrently (with a set max concurrency)
GitHub - almost/through2-concurrent: Simple Node.JS stream (streams2) Transform that runs the transform functions concurrently (with a set max concurrency)
Google I/O 2013 - Accelerating Oz with V8: Follow the Yellow Brick Road to JavaScript Performance
Google I/O 2013 - Accelerating Oz with V8: Follow the Yellow Brick Road to JavaScript Performance
babel/packages/babel-parser at master · babel/babel
babel/packages/babel-parser at master · babel/babel
GitHub - SheetJS/sheetjs: 📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
GitHub - SheetJS/sheetjs: 📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs
GitHub - sindresorhus/log-symbols: Colored symbols for various log levels
GitHub - sindresorhus/log-symbols: Colored symbols for various log levels
GitHub - Raathigesh/atmo: :heavy_check_mark: Mock data for your prototypes and demos. Remote deployments to Zeit now.
GitHub - Raathigesh/atmo: :heavy_check_mark: Mock data for your prototypes and demos. Remote deployments to Zeit now.
GitHub - tapio/live-server: A simple development http server with live reload capability.
GitHub - tapio/live-server: A simple development http server with live reload capability.
GitHub - pawurb/normit: Translations with speech synthesis in your terminal as a node package
GitHub - pawurb/normit: Translations with speech synthesis in your terminal as a node package
GitHub - lodash/lodash: A modern JavaScript utility library delivering modularity, performance, & extras.
GitHub - lodash/lodash: A modern JavaScript utility library delivering modularity, performance, & extras.
Node JS Internal Architecture | Ignition, Turbofan, Libuv
Node JS Internal Architecture | Ignition, Turbofan, Libuv
GitHub - chalk/chalk: 🖍 Terminal string styling done right
GitHub - chalk/chalk: 🖍 Terminal string styling done right
GitHub - sindresorhus/awesome-observables: Awesome Observable related stuff - An Observable is a collection that arrives over time.
GitHub - sindresorhus/awesome-observables: Awesome Observable related stuff - An Observable is a collection that arrives over time.
GitHub - patrickjuchli/basic-ftp: FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript.
GitHub - patrickjuchli/basic-ftp: FTP client for Node.js, supports FTPS over TLS, passive mode over IPv6, async/await, and Typescript.
GitHub - codeceptjs/CodeceptJS: Supercharged End 2 End Testing Framework for NodeJS
GitHub - codeceptjs/CodeceptJS: Supercharged End 2 End Testing Framework for NodeJS
Newest 'node.js' Questions
Newest 'node.js' Questions
You Don't Know Node - ForwardJS San Francisco
You Don't Know Node - ForwardJS San Francisco
Node.js in Action, Second Edition
Node.js in Action, Second Edition
Google I/O 2009 - V8: ..High Performance JavaScript Engine
Google I/O 2009 - V8: ..High Performance JavaScript Engine
stackgl
stackgl
GitHub - MrRio/vtop: Wow such top. So stats. More better than regular top.
GitHub - MrRio/vtop: Wow such top. So stats. More better than regular top.
GitHub - nut-tree/nut.js: Native UI testing / controlling with node
GitHub - nut-tree/nut.js: Native UI testing / controlling with node
GitHub - mafintosh/pumpify: Combine an array of streams into a single duplex stream using pump and duplexify
GitHub - mafintosh/pumpify: Combine an array of streams into a single duplex stream using pump and duplexify
GitHub - sindresorhus/cli-cursor: Toggle the CLI cursor
GitHub - sindresorhus/cli-cursor: Toggle the CLI cursor
GitHub - sindresorhus/fkill-cli: Fabulously kill processes. Cross-platform.
GitHub - sindresorhus/fkill-cli: Fabulously kill processes. Cross-platform.
GitHub - retextjs/retext: natural language processor powered by plugins part of the @unifiedjs collective
GitHub - retextjs/retext: natural language processor powered by plugins part of the @unifiedjs collective
GitHub - sindresorhus/trash: Move files and directories to the trash
GitHub - sindresorhus/trash: Move files and directories to the trash
Node.js
More on Node.js

Programming Tips & Tricks

Code smarter, not harder—insider tips and tricks for developers.

Error Solutions

Turn frustration into progress—fix errors faster than ever.

Shortcuts

The art of speed—shortcuts to supercharge your workflow.
  1. Collections 😎
  2. Frequently Asked Question's 🤯

Tools

available to use.

Made with ❤️

to provide resources in various ares.