Preview Image in CLI.

Overview

PIC ๐Ÿ“ท

PIC (Preview Image in CLI ) is a lightweight Rust tool to preview images in your terminal!
With support for various image protocols (Kitty, Sixel, iTerm) it works in several terminals, and can still use Unicode blocks in case your terminal isn't supported. PIC also provides a library for you to use in your own tools!

Features

  • Choose your favourite protocols
    • Kitty graphics with multiple actions available (load/clear)
    • Sixel which works in a lot of terminals
    • iTerm which displays GIFs incredibly well
    • Unicode blocks with truecolor/ansi256 support otherwise
  • Customization
    • --x and --y options to choose where to display your image
    • --cols and --rows options to choose the size of your image (always tries preserving ratio)
    • --upscale option to preview image at full wanted size if needed
    • --static and --loop options to interact with GIFs
    • --protocol option to choose a protocol
    • --load --display and --clear options to interact with Kitty protocol

Installation

From source (Recommended)

Prerequisites

Command line instructions

# Clone the repository
git clone https://github.com/emsquid/pic

# Build and install
cargo install --path pic

# Use freely
pic Images/YourFavouriteImage.png --cols 13 ...

From Cargo

Prerequisites

Command line instructions

# Build and install
cargo install pic

# Use freely again
pic Images/YourFavouriteImage.png --cols 13 ...

As a library

Prerequisites

Command line instructions

# Add the dependency in your project directory
cargo add pic

Examples

Blocks & Top quality previewing

demo demo

Wide choice of options

options

Really nice GIFs in iTerm

iterm

And also nice in Blocks

gotcha

Command line usage

Preview Image in CLI.

Usage: pic [OPTIONS] <PATH>

Arguments:
  <PATH>  Image to preview

Options:
  -x, --x <X>                x position (0 is left)
  -y, --y <Y>                y position (0 is top)
  -c, --cols <COLS>          Number of cols to fit the preview in
  -r, --rows <ROWS>          Number of rows to fit the preview in
  -u, --upscale              Upscale image if needed
  -s, --static               Only show first frame of GIFs
  -l, --loop                 Loop GIFs infinitely
  -p, --protocol <PROTOCOL>  Previewing protocol to use [possible values: kitty, sixel, iterm, blocks]
      --load <ID>            Load image with the given id (kitty only)
      --display <ID>         Display image with the given id (kitty only)
      --clear <ID>           Clear image with the given id (0 for all) (kitty only)
  -h, --help                 Print help
  -V, --version              Print version

Library usage

use pic

fn main() {
    // Choose images to preview
    let path1 = std::path::PathBuf::from("Picture/MyFavImage.png");
    let mut options = pic::options::Options::new(vec![path1]);

    // Set your options
    options.set_position(Some(10), None);
    options.set_size(Some(50), Some(50));
    options.upscale();

    // Preview
    if let Err(err) = pic::previewer::preview(&mut std::io::stdout(), &mut options) {
        eprintln!("{err}");
    };
}

Notes

  • Sixel protocol may require libsixel to be installed
  • iTerm protocol always loop GIFs, except if --static is specified

Progress

Help would be greatly appreciated

  • Documentation
    • Write a greater README
    • Make releases/packages (publish on crates.io)
  • Protocols support
    • Preview GIFs with Kitty protocol
    • Preview GIFs with Unicode blocks
    • Work on handling transparency/GIFs with Sixel protocol (GIFs work but don't render well)
    • Improve protocol support checking (need to test in various terminal)
  • Miscellaneous
    • Implement caching somehow
    • Show cooler error messages
    • Write tests (I guess I need to do that...)
You might also like...
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.
By mirroring traffic to and from your machine, mirrord surrounds your local service with a mirror image of its cloud environment.

mirrord lets you easily mirror traffic from your Kubernetes cluster to your development environment. It comes as both Visual Studio Code extension and

Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

Failed experiment in downloading random cat image, turning it into ascii and displaying it in Neovim.

cat.nvim Failed experiment in downloading random cat image, turning it into ascii and displaying it in Neovim. Failed as I realized far too late, that

Desmos command-line image uploader.

๐Ÿงฎ demsos Desmos command-line image uploader. ๐Ÿ—บ๏ธ Features Support for a "vanity hash" (10 character limit) Upload raw image to the graph and the embe

A little program written in Rust that prints random PNG images to the terminal in text grabbed from an image repo.

Cermic A little program written in Rust that prints random PNG images to the terminal in text grabbed from an image repo. NOTE: As of right now, Cermi

Advanced image to ascii art fully created with rust ๐Ÿฆ€ ๐Ÿš€
Advanced image to ascii art fully created with rust ๐Ÿฆ€ ๐Ÿš€

RASCII image to ascii art fully created with rust ๐Ÿฆ€ ๐Ÿš€ multiple language character lists - โœ”๏ธ creatable custom char list - โœ”๏ธ pixel art creaton -

SAORI for UKAGAKA. Convert a image file to resized png file.

Resized Png GitHub repository ใ“ใ‚Œใฏไฝ•? ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—ใƒžใ‚นใ‚ณใƒƒใƒˆใ€ใ€Œไผบใ‹ใ€ใงไฝฟ็”จใงใใ‚‹SAORIใฎไธ€็จฎใงใ™ใ€‚ ๆฉŸ่ƒฝใจใ—ใฆใฏใ€ๆŒ‡ๅฎšใ—ใŸ็”ปๅƒใƒ•ใ‚กใ‚คใƒซใ‚’ๆ‹กๅคงใพใŸใฏ็ธฎๅฐใ—ใ€pngใจใ—ใฆๅ‡บๅŠ›ใ—ใพใ™ใ€‚ ใ€Œไผบใ‹ใ€ใ€ŒSAORIใ€็ญ‰ใฎ็”จ่ชžใซใคใ„ใฆใฏ่ฉณใ—ใ่ชฌๆ˜Žใ„ใŸใ—ใพใ›ใ‚“ใฎใงใ”ไบ†ๆ‰ฟไธ‹ใ•ใ„ใ€‚

Demo app duplicated in 5 languages (Go/JavaScript/Python/Ruby/Rust) showing how to go from source code to container image using melange+apko

hello-melange-apko ๐Ÿ’ซ This repo contains an example app duplicated across 5 languages showing how to: Package source code into APKs using melange Buil

A container image builder tool for OCI (distrobox/toolbox, also podman/docker)

Distrobox Boost A container image builder tool for Open Container Initiative (distrobox/toolbox, also podman/docker). Distrobox is good enough in runn

Comments
  • Feature/multiple preview

    Feature/multiple preview

    Feature

    Allow the use of wildcards to display more than one image.

    Examples

    pic -p iterm ~/Pictures/*.jpg
    

    to display all .jpg images inside the Pictures directory.

    pic ./*/*.png
    

    to display all .png images inside any directory with depth 1 relative to pwd.

    TODO

    • [ ] Display all image files if a directory is selected in path (Probably another PR)
    • [ ] Allow grid display of images (Another PR, big changes)
    opened by Maratripa 20
  • fix: change wezterm default protocol

    fix: change wezterm default protocol

    Tested both kitty and iTerm protocols on Wezterm and found that iTerm has better resolution and is faster than kitty. Changed order of support checking so it uses iTerm by default.

    opened by Maratripa 1
  • fix: guess format with kitty protocol

    fix: guess format with kitty protocol

    Had an issue Image error: Format error decoding Jpeg: Invalid JPEG format: first two bytes are not an SOI marker with kitty protocol when trying to open an image with the wrong file extension.

    Fix: Make kitty protocol open images with io::Reader to use with_guessed_format.

    opened by Maratripa 0
  • Fix a divide by zero error

    Fix a divide by zero error

    Commits:

    • fix divide by zero by handling inappropriate ioctl's
    • add a gitignore

    The divide by zero error occured on an inappropriate ioctl, such as a redirected stdout. Originally this caused the program to panic, but now those errors are handled in a more "Rusty" way.

    opened by dtomvan 0
Owner
emanuel
emanuel
Save image from your clipboard ๐Ÿ“‹ as an image file directly from your command line! ๐Ÿ”ฅ

Clpy ?? Save copied image from clipboard as an image file directly from your command line! Note It works only on windows as of now. I'll be adding sup

Piyush Suthar 13 Nov 28, 2022
Conference Monitoring Project based on Image Recognition that uses Rust Language and AWS Rekognition service to get the level of image similarity.

Conference Monitoring System based on Image Recognition in Rust This is a Conference Monitoring Project based on Image Recognition that uses Rust Lang

Pankaj Chaudhary 6 Dec 18, 2022
A CLI tool to find the dominant colours in an image ๐ŸŽจ

dominant_colours This is a command-line tool for finding the dominant colours of an image. It prints their hex codes to the terminal, along with a pre

Alex Chan 65 Nov 10, 2022
CLI tool to convert image files.

?? F1sh CLI tool to convert image files. ??๏ธ Supported formats File Supported AviF โœ… BMP โœ… DDS โœ… Farbfeld โœ… GIF โœ… HEIF โŒ ICO โœ… JPEG โœ… OpenEXR โœ… PNG โœ…

Sammwy 5 Apr 3, 2023
Command-Line program that takes images and produces the copy of the image with a thin frame and palette made of the 10 most frequent colors.

paleatra v.0.0.1 Command-Line program that takes an image and produces the copy of the image with a thin frame and palette made of the 10 most frequen

Beka Modebadze 24 Dec 29, 2022
TUI image viewer

Picterm TUI image viewer install $ cargo install picterm or $ git clone https://github.com/ksk001100/picterm $ cd picterm $ cargo install --path . usa

Keisuke Toyota 41 Dec 31, 2022
A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere

A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere

Jake Wharton 256 Dec 27, 2022
A lightweight ShareX-compatible image uploader server

Imitari Imitari is a project to provide an easy and lightweight server for images. It is compatible with software like ShareX. The projects goals are

Imitari 12 May 5, 2022
A command line application which sets your wall paper with new image generating pollens once they arrive.

pollenwall Table of Contents pollenwall About Installation Binary releases Build from source Usage Command Line Arguments Running as a service MacOS L

Pollinations.AI 2 Jan 7, 2022
A command-line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the returned URL.

Pup A command line tool aiming to upload the local image used in your markdown file to the GitHub repo and replace the local file path with the return

SteveLau 11 Aug 17, 2022