A simple and powerful Rust CLI application to display images in non visual interfaces (for example, ssh).
Just run this command to install the application:
curl -s https://raw.githubusercontent.com/wikiti/imgprev/master/install.sh | sh
and the application will be directly installed into the /usr/local/bin
folder as imgprev
.
You can download the binary files from the releases section, or build it by yourself with Rust. After that, place the binary file in a directory accessible by PATH (e.g. in /usr/bin/). Otherwise, you may want to put the executable in any folder, and prefix the executable with corresponding directory path (e.g. /home/test/dev/imgprev).
Please bear in mind that this application must be installed in the target machine if you are ussing ssh.
Once installed, you can use the program within your favourite command line:
imgprev path/to/my/image/cat.jpg
Which should output something like this:
Cute, isn't it? Now, you can preview images in a non-GUI enviroment without downloading the file!
By default, the image will be scalated to fit into the console (around 100 columns wide).
To know more about the available options, use
imgprev --help
or check the Options section of this file.
These are the image extensions supported by this application:
- Portable Network Graphics (png)
- Joint Photographic Experts Group (jpeg, jpg, jpe, jif, jfif, jfi)
- Graphics Interchange Format (gif)
- Windows Bitmap (bmp, dib)
- ICO (ico)
- Tagged Image File Format (tiff, tif)
- WebP (webp)
Used with the -m
or --mode
option.
Multiple render modes are supported for this application. The following table summarizes them:
Name | Description |
---|---|
ansi | Use ansi colors (256) to render the image. This is the default mode. |
grayscale | Same as ansy, but using grayscale colors. |
true_color | Use true color mode (rgb). Not supported in many terminals. |
text | Use ascii characters to represent the image. Ideal for simple terminals without color support. |
For example, the same image in different modes:
And, as a bonus, a cat in ascii :
Used with the -w
or --width
option; it sets the maximum width to fit the image. Each image pixel equals to 2 console characters. Use any value greater than 0.
For example, two different outputs for different sizes. With max width 30:
$ imgprev samples/ubuntu.png -w 30
which will output this:
while this, with max width 15:
$ imgprev samples/ubuntu.png -w 15
will output this:
Used with the -f
or --filter
option.
This application allow to use multiple resize filters or algorithms:
- none: Use the nearest neighbour (pixel).
- linear: Create a linear interpolation between pixels.
- cubic: Create a cubir interpolation between pixels
- gaussian: Use a gaussian function to compute the pixel's value.
- lanczos3: Lanczos algorithm with window's size 3.
Here is a example of the available filters for a single image (in true color):
This project was developed using Rust v1.11.0. It uses the following crates:
- image: Image file handling for Rust.
- lazy_static: Lazy initialization for static references.
- clap-rs: A powerful library to create CLI applications.
Clone this repository and install it with:
git clone https://github.com/wikiti/imgprev.git
cd imgprev
cargo build --release
target/release/imgprev examples/ubuntu.png
Use cargo to run unit tests:
cargo test
This project has been developed by:
Avatar | Name | Nickname | |
---|---|---|---|
Daniel Herzog | Wikiti | [email protected] |