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

climg

v2.1.1

Published

Render PNG and JPEG images beautifully in your terminal using ANSI colors and Unicode blocks.

Readme

Print image in your terminal

A Node.js utility that displays images directly in your terminal using ANSI escape codes and Unicode characters.

Features

  • Display PNG and JPEG images in the terminal
  • True color (24-bit RGB) support for high-quality rendering
  • Fallback to 256-color mode for older terminals
  • Flexible sizing with pixel or percentage values
  • Automatic image resizing to fit terminal dimensions
  • No external commands required - pure JavaScript implementation

Installation

npm install climg -g

Usage

Basic Usage

Display an image with default settings (fills terminal width):

climg image.jpg

Size Options

Set custom width and height using pixels:

climg image.jpg -w 100 -h 30

Set custom width and height using percentages:

climg image.jpg -w 50% -h 80%

Set only width (height will be calculated to maintain aspect ratio):

climg image.jpg -w 120

Set only height (width will be calculated to maintain aspect ratio):

climg image.jpg -h 40

Color Mode

Disable true color and use 256-color mode instead:

climg image.jpg -t

Command Line Options

Usage: climg <image.png|jpg> [options]

Options:
  -w <size>      Set width in pixels or percentage (e.g., 80 or 50%)
  -h <size>      Set height in pixels or percentage (e.g., 40 or 80%)
  -t             Disable true color, use 256 colors instead

Examples

Display a photo at 75% of terminal width:

climg photo.jpg -w 75%

Display a logo at exact dimensions:

climg logo.png -w 60 -h 20

Display using 256 colors for compatibility:

climg image.jpg -w 100 -t

How It Works

  1. Loading and decoding PNG or JPEG images using pngjs and jpeg-js libraries
  2. Resizing the image to fit the specified or terminal dimensions
  3. Converting RGB pixel values to ANSI escape codes
  4. Using the half-block character (▀) to display two vertical pixels per character
  5. Setting foreground color for the top pixel and background color for the bottom pixel

Supported Formats

  • PNG (.png)
  • JPEG (.jpg, .jpeg)

Terminal Compatibility

Works best with terminals that support true color (24-bit):

  • iTerm2 (macOS)
  • Windows Terminal
  • GNOME Terminal (recent versions)
  • Konsole
  • Alacritty
  • Kitty
  • Hyper

For older terminals, use the -t flag to enable 256-color mode.

Requirements

  • Node.js (version 10 or higher)
  • Terminal with ANSI color support

API Usage

You can also use climg as a module in your own Node.js programs:

import { climg, loadImage, renderImage, ClimgOptions, ImageData } from "climg";

(async () => {
  // Define rendering options (with full IntelliSense)
  const options: ClimgOptions = {
    width: 100,
    height: 30,
    trueColor: true,
  };

  // Display an image directly in the terminal
  await climg("image.jpg", options);

  // Load an image and inspect its pixel data
  const image: ImageData = await loadImage("image.jpg");
  console.log(`Image dimensions: ${image.width}x${image.height}`);

  // Render the image to an ANSI string (instead of printing directly)
  const output: string = renderImage(image.pixels, {
    width: 80,
    trueColor: true,
  });

  // Print the ANSI-rendered image manually
  console.log(output);
})();

You can also run it in plain JavaScript (same syntax, just replace import with require).

Notes

  • Size percentages are calculated based on terminal dimensions at runtime
  • When only width or height is specified, the aspect ratio is preserved
  • Image quality depends on terminal color support and font rendering
  • Very large images are automatically scaled down to fit the terminal