A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

Overview

EmojiPix

This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji. One good use for this might be making pixel art in Discord, in posts or in your own profile. For example, if you use emoji_pix ferris.png --width 30 on the Ferris (Rust's mascot) picture downloaded from here, and paste the output into Discord (over several messages), it will look like this:

CLI Installation and Usage

  1. Make sure Rust is installed
  2. Run cargo install emoji_pix
  3. Run the binary using emoji_pix [options]. For example, emoji_pix ferris.png --width 30.

The full CLI options are obtained using emoji_pix --help.

Rust Crate Usage

  1. Install the crate by adding emoji_pix = "0.1.0" to your Cargo.toml
  2. Refer to the documentation here

Usage Tips

  • If your source image has a transparent background, try editing the image and replacing the background with a solid colour that isn't already in the image. This is because transparency gets automatically converted to black, which may not give you good contrast for your image.
  • For reasons explain below, the resulting "pictures" will look best on platforms that use Twemoji, such as Twitter and Discord.
  • On discord, messages can only be 2000 characters long at most. What this means is that you'll often have to split up the large pictures over several messages, but this still looks good, as demonstrated by the above example.
  • On some other platforms, putting the pixel art inside a monospaced font or code block will generally give a more pleasing result.

How it Works

The emoji standard has 9 rectangle boxes of different colours: 🟥 🟧 🟨 🟩 🟦 🟪 🟫 . They can be used as pseudo pixels in pixel art. Because the emoji standard doesn't specify a particular shade of colour for each box, EmojiPix currently works under the assumption that you are using Twemoji. Certain applications such as Twitter and Discord use these emoji implementations.

EmojiPix then:

  1. Resizes the image according to the user's input, maintaining the correct aspect ratio
  2. For each pixel, finds the most similarly coloured emoji, using the CIEDE2000 colour distance algorithm, and prints it.

Future Directions

  • Automated binary builds, meaning that you don't have to have Rust installed to use this.
  • Customizable emoji set, to remove the assumption you are using Twemoji. This would allow you to get more accurate images on platforms that aren't using Twemoji. The emoji set would then be provided as a flag on the command-line.
  • Allow reading the image from memory, rather than requiring a file path.
  • Compile for WASM and make this into a web app
  • Automatically separate image chunks for posting on discord, to cater for the 2000 character message limit
You might also like...
Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner
Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

PNG decoding and encoding library in pure Rust

PNG Decoder/Encoder PNG decoder/encoder in pure Rust. It contains all features required to handle the entirety of the PngSuite by Willem van Schack. p

A support tool for creating shaders that display pixel arts.

dot2shader -- PRE-BUILD PAGE IS HERE -- A tool for generating shaders displaying pixel art textures in Shadertoy and twigl. Quick start Go to pre-bu

Oxipng - a multithreaded lossless PNG compression optimizer

Oxipng Overview Oxipng is a multithreaded lossless PNG compression optimizer. It can be used via a command-line interface or as a library in other Rus

A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls!
A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls!

regretti 🍝 A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls! Made for Lang Jam (jam0001) t

My personal project for generative art.

Generative Art This is my personal project for making Generative Art. Installation There are three ways of getting the binary. You can either download

A cross platform reloading image viewer combined with a command executor
A cross platform reloading image viewer combined with a command executor

Watchout A cross platform reloading image viewer combined with a command executor. Watchout will do any of the following: Run a command when any file

Simple image metadata scrubber. Will remove EXIF, XMP and IPTC metadata.

Simple image metadata scrubber. Will remove EXIF, XMP and IPTC metadata.

Comments
  • Unable to build using `cargo install emoji_pix`

    Unable to build using `cargo install emoji_pix`

    I installed rustup following this

    rustup --version returns:

    rustup 1.24.3 (ce5817a94 2021-05-31)
    info: This is the version for the rustup toolchain manager, not the rustc compiler.
    info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
    

    cargo --version returns:

    cargo 1.59.0 (49d8809dc 2022-02-10)
    

    cargo install emoji_pix returns an error:

       Compiling scarlet v1.1.0
       Compiling emoji_pix v0.2.0
    error[E0432]: unresolved imports `clap::Clap`, `clap::crate_authors`, `clap::crate_version`
     --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:4:25
      |
    4 | use clap::{AppSettings, Clap, crate_authors, crate_version};
      |                         ^^^^  ^^^^^^^^^^^^^  ^^^^^^^^^^^^^ no `crate_version` in the root
      |                         |     |
      |                         |     no `crate_authors` in the root
      |                         no `Clap` in the root
    
    error: cannot determine resolution for the derive macro `Clap`
      --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:38:10
       |
    38 | #[derive(Clap)]
       |          ^^^^
       |
       = note: import resolution is stuck, try simplifying macro imports
    
    error: cannot find attribute `clap` in this scope
      --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:39:3
       |
    39 | #[clap(setting = AppSettings::ColoredHelp, version = crate_version!(), author = crate_authors!("\n"))]
       |   ^^^^
       |
       = note: `clap` is in scope, but it is a crate, not an attribute
    
    error: cannot find attribute `clap` in this scope
      --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:47:7
       |
    47 |     #[clap(short, long)]
       |       ^^^^
       |
       = note: `clap` is in scope, but it is a crate, not an attribute
    
    error: cannot find attribute `clap` in this scope
      --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:52:7
       |
    52 |     #[clap(short, long)]
       |       ^^^^
       |
       = note: `clap` is in scope, but it is a crate, not an attribute
    
    error: cannot find attribute `clap` in this scope
      --> /home/z0rg0n/.cargo/registry/src/github.com-1ecc6299db9ec823/emoji_pix-0.2.0/src/lib.rs:57:7
       |
    57 |     #[clap(default_value = "Gaussian", short, long)]
       |       ^^^^
       |
       = note: `clap` is in scope, but it is a crate, not an attribute
    
    For more information about this error, try `rustc --explain E0432`.
    error: could not compile `emoji_pix` due to 6 previous errors
    warning: build failed, waiting for other jobs to finish...
    error: failed to compile `emoji_pix v0.2.0`, intermediate artifacts can be found at `/tmp/cargo-install6oTHpu`
    
    Caused by:
      build failed
    

    More detail on the error using rustic --explain E0432:

    
    An import was unresolved.
    
    Erroneous code example:
    
    
    use something::Foo; // error: unresolved import `something::Foo`.
    
    
    In Rust 2015, paths in `use` statements are relative to the crate root. To
    import items relative to the current and parent modules, use the `self::` and
    `super::` prefixes, respectively.
    
    In Rust 2018, paths in `use` statements are relative to the current module
    unless they begin with the name of a crate or a literal `crate::`, in which
    case they start from the crate root. As in Rust 2015 code, the `self::` and
    `super::` prefixes refer to the current and parent modules respectively.
    
    Also verify that you didn't misspell the import name and that the import exists
    in the module from where you tried to import it. Example:
    
    
    use self::something::Foo; // Ok.
    
    mod something {
        pub struct Foo;
    }
    
    
    If you tried to use a module from an external crate and are using Rust 2015,
    you may have missed the `extern crate` declaration (which is usually placed in
    the crate root):
    
    
    extern crate core; // Required to use the `core` crate in Rust 2015.
    
    use core::any;
    
    
    In Rust 2018 the `extern crate` declaration is not required and you can instead
    just `use` it:
    
    
    use core::any; // No extern crate required in Rust 2018.
    

    Not sure what I'm doing wrong. I've never used Rust before.

    opened by z0rg0n 2
  • Support use of any emoji, not just squares

    Support use of any emoji, not just squares

    • This would be a bit tricky, as we would have to download the full emoji set, and determine a representative colour for each
    • Then, if the user provides enables this feature, we find the closest emoji for each pixel in the image
    enhancement 
    opened by multimeric 0
  • Customizable emoji set

    Customizable emoji set

    • Removes the assumption you are using Twemoji.
    • This would allow you to get more accurate images on platforms that aren't using Twemoji.
    • The emoji set would then be provided as a flag on the command-line.
    enhancement good first issue 
    opened by multimeric 0
Add image watermark for multiple file (jpeg, jpg, png, tiff, bmp,etc)

Rust image watermark Add image watermark CLI program for multiple image format (jpeg, jpg, png, tiff, bmp, etc.) manipulation, browser WASM build supp

Johnathan 5 Jan 20, 2023
Control Google Pixel Buds Pro from the Linux command line.

pbpctrl Control Google Pixel Buds Pro from the Linux command line. Might or might not work on other Pixel Buds devices. Allows reading of battery, har

Maximilian Luz 6 Jan 10, 2023
Converts images into textual line art.

img2utf Transform images to textual line art! Images require pre-processing to come out nice. It's expected that users will do the following: Apply ga

Lee 149 Dec 10, 2022
Artsy pixel image to vector graphics converter

inkdrop inkdrop is an artsy bitmap to vector converter. Command line interface The CLI binary is called inkdrop-cli and reads almost any image bitmap

Matthias Vogelgesang 62 Dec 26, 2022
Refract - A guided AVIF/JPEG XL/WebP conversion utility for JPEG and PNG sources.

Refract GTK Refract is a guided image conversion tool written in Rust for x86-64 Linux systems with GTK. It takes JPEG and PNG image sources and produ

Blobfolio 34 Nov 28, 2022
CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console)

CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console). Supports most standard image formats, and some video formats.

Michael 30 Jan 1, 2023
a cute language with a bunch emoji🐶

nylang a cute language with a bunch emoji documentation WIKI usage dependancies rust ( cargo ) install & uninstall install chmod +x scripts/install.sh

jumango pussu 13 Jul 4, 2022
PixelWorldProxy - Simple Pixel World Proxy made in Rust.

PixelWorldProxy Simple Pixel World Proxy made in Rust. Feature Safe and fast Support subserver switching Usage Clone the repository: git clone https:/

null 3 Jan 5, 2022
Signed distance field font and image command line tool based on OpenCL.

SDFTool Signed distance field font and image command line tool based on OpenCL. Build Windows Run cargo build --release in Visual Studio developer x64

弦语蝶梦 7 Oct 16, 2022
Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Takes a folder of images (as a palette), and an image, and figures out how to tile the palette to resemble the image!

Jacob 258 Dec 30, 2022