Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/orhnk/RASCII

Advanced image to ASCII art tool & crate written in Rust 🦀🚀
https://github.com/orhnk/RASCII

art ascii ascii-art command-line img img2ascii rust

Last synced: 13 days ago
JSON representation

Advanced image to ASCII art tool & crate written in Rust 🦀🚀

Awesome Lists containing this project

README

        

[![Crate Status](https://img.shields.io/crates/v/rascii_art.svg)](https://crates.io/crates/rascii_art)
[![Docs Status](https://docs.rs/rascii_art/badge.svg)](https://docs.rs/crate/rascii_art/)


RASCII Logo


```
Advanced ASCII Art Generator

Usage: rascii [OPTIONS]

Arguments:
Path to the image

Options:
-w, --width Width of the output image. Defaults to 128 if width and height are not specified
-H, --height Height of the output image, if not specified, it will be calculated to keep the aspect ratio
-c, --color Whether to use colors in the output image
-i, --invert Inverts the weights of the characters. Useful for white backgrounds
-C, --charset Characters used to render the image, from transparent to opaque. Built-in charsets: block, emoji, default, russian, slight [default: default]
-h, --help Print help
-V, --version Print version
```

## Features

- **Available as a crate:** RASCII has a very simple API allowing you to use
RASCII from your programs without using the system shell.

- **Colored ASCII art generation**: RASCII uses ANSI color codes to generate
colored ASCII art.


> [!NOTE]
> Your terminal emulator has to support `truecolor` (don't worry,
> almost all modern terminal emulators do).

- **Super efficient colored output**: RASCII never repeats the same ANSI color
code if it is already active.
> This makes a huge difference in images with little alternating color, up to
> about 1800% reduction in output size. Woah!

- **Custom dimensions**: RASCII allows you to give custom dimensions to the
outputted ASCII art while keeping the aspect ratio (unless both dimensions are
provided).

- **Custom charsets:** RASCII allows you to use custom charsets to generate your
ASCII art.

> [!NOTE]
> The given charset must go from transparent to opaque.

- **Lots of pre-included charsets.**

## Installing The CLI

## Via Cargo

> [!NOTE]
> This is the recommended way of installing the RASCII CLI.

> [!WARNING]
> You must have `~/.cargo/bin/` in your `PATH` to run `rascii`
> directly.

```sh
cargo install rascii_art
```

## Manually

> [!WARNING]
> this installation method is discouraged and only works for
> GNU/Linux or any other POSIX compatible systems!

```sh
git clone https://github.com/KoBruhh/RASCII && cd RASCII
chmod +x install.sh
./install.sh
```

## Using The Crate

Instead of using the unreliable system shell to call RASCII, you can add the
`rascii_art` crate to your project and use it in Rust!

To do so, run `cargo add rascii_art` to add RASCII to your Cargo project.

Here is a code example:

```rs
use rascii_art::{
render_to,
RenderOptions,
};

fn main() {
let mut buffer = String::new();

render_to(
r"/path/to/image.png",
&mut buffer,
&RenderOptions::new()
.width(100)
.colored(true)
.charset(&[".", ",", "-", "*", "£", "$", "#"]),
)
.unwrap();
}
```

## Showcase

### Japanese Charset



### Emoji Charset

> [!NOTE]
> The emoji charset does not guarantee your outputs color will match
> the color of your image, this is just a coincidence that happened with Ferris.



### Chinese Charset



### Block Charset



### Custom ASCII Charset

You can use the `--charset` (or `-C`) CLI option to provide a custom charset to
use when generating some ASCII art.

The value of this must option must go from transparent to opaque, like so:

```sh
rascii --charset " â–‘â–’â–“â–ˆ" --color ferris.png
```

Note that a charset similar to the above charset is available as a builtin named
`block`.



### Contributors

![KoBruhh](https://github.com/KoBruhh/RASCII/assets/101834410/2b06a6b0-9cb9-448e-8979-4a5182e2e4b2)
![RGBCube](https://github.com/KoBruhh/RASCII/assets/101834410/3e5b18c3-d7c8-4862-bee5-b5cf06c83994)
![felixonmars](https://github.com/KoBruhh/RASCII/assets/101834410/66914a48-a5c5-4619-a46d-b99c77b3cd77)
![fnordpig](https://github.com/fnordpig/RASCII/assets/1621189/5b3225f3-ae83-4ed3-a3fb-3d88de18f82e)

---

> [!NOTE]
> There is a python script at repository root that can be used to generate
> the above contributor ASCII Art.
>
> ```sh
> python contributors.py
> ```