All Projects β†’ sindresorhus β†’ Terminal Image

sindresorhus / Terminal Image

Licence: mit
Display images in the terminal

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Terminal Image

Defer.js
πŸ₯‡ A super small, super efficient library that helps you lazy load everything like images, video, audio, iframe as well as stylesheets, and JavaScript.
Stars: ✭ 138 (-82.26%)
Mutual labels:  image, npm-package
Term Img Cli
Display images in iTerm
Stars: ✭ 70 (-91%)
Mutual labels:  image, npm-package
Terminal Image Cli
Display images in the terminal
Stars: ✭ 234 (-69.92%)
Mutual labels:  image, npm-package
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-88.17%)
Mutual labels:  image, npm-package
Term Img
Display images in iTerm
Stars: ✭ 275 (-64.65%)
Mutual labels:  image, npm-package
Vue Progressive Image
Vue progressive image loading plugin
Stars: ✭ 684 (-12.08%)
Mutual labels:  image
Bundlephobia
πŸ‹οΈ Find out the cost of adding a new frontend dependency to your project
Stars: ✭ 6,640 (+753.47%)
Mutual labels:  npm-package
Sota Medseg
SOTA medical image segmentation methods based on various challenges
Stars: ✭ 677 (-12.98%)
Mutual labels:  image
React Native Fast Image
🚩 FastImage, performant React Native image component.
Stars: ✭ 6,500 (+735.48%)
Mutual labels:  image
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (-2.06%)
Mutual labels:  image
React Native Img Cache
Image Cache for React Native
Stars: ✭ 724 (-6.94%)
Mutual labels:  image
Ueberzug
ueberzug is a command line util which allows to display images in combination with X11
Stars: ✭ 711 (-8.61%)
Mutual labels:  image
Progressively
A JavaScript library to load images progressively πŸŒ‡
Stars: ✭ 691 (-11.18%)
Mutual labels:  image
Np
A better `npm publish`
Stars: ✭ 6,401 (+722.75%)
Mutual labels:  npm-package
Sakurakit
🀑SakuraKit, a lightweight and powerful library for application to switching themes or skins.
Stars: ✭ 682 (-12.34%)
Mutual labels:  image
Eslint Plugin Node
Additional ESLint's rules for Node.js
Stars: ✭ 740 (-4.88%)
Mutual labels:  npm-package
Bbmetalimage
A high performance Swift library for GPU-accelerated image/video processing based on Metal.
Stars: ✭ 677 (-12.98%)
Mutual labels:  image
Conf
Simple config handling for your app or module
Stars: ✭ 707 (-9.13%)
Mutual labels:  npm-package
Flutter image cropper
A Flutter plugin for Android and iOS supports cropping images
Stars: ✭ 723 (-7.07%)
Mutual labels:  image
Glightbox
Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
Stars: ✭ 702 (-9.77%)
Mutual labels:  image

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

const terminalImage = require('terminal-image');

(async () => {
	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.

const terminalImage = require('terminal-image');

(async () => {
	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.

const terminalImage = require('terminal-image');

(async () => {
	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.

const terminalImage = require('terminal-image');

(async () => {
	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

const terminalImage = require('terminal-image');
const got = require('got');

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

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].