eth-blockies-rs

binary-example.png

A lightweight library in pure Rust to get raw data of Ethereum-style blocky identicon, which can be used for generating blockies icon images, printing to terminal, etc.

Useful when getting raw RGB data of Ethereum-style blockies, as well as complete png image files.

Supports general Rust bin/lib, and WebAssembly (wasm) target.

Live Demo

library-example.png

Library

Documentation

Prerequisites

Library Basic Usage

  1. Define a blockies type (size) to use

    // Blockies < size (const), T > type Icon = Blockies<15, T>; ```

  2. Select an input seed type

    let seedfromstr = "0xe686c14FF9C11038F2B1c9aD617F2346CFB817dC" .toethaddrseed(); let fromstr = EthBlockies::data(seedfrom_str);

    let seedfrombytes = [ 0xe6, 0x86, 0xc1, 0x4f, 0xf9, 0xc1, 0x10, 0x38, 0xf2, 0xb1, 0xc9, 0xad, 0x61, 0x7f, 0x23, 0x46, 0xcf, 0xb8, 0x17, 0xdc, ].toethaddrseed(); let frombytes = EthBlockies::data(seedfrom_bytes);

    ```

  3. Select an output data type

Example

Cargo Features

Binary

Install

console $ cargo install eth-blockies

Binary Usage

```text usage: eth-blockies [output-fmt (ansi|image)] [OPTIONS...]

Seed to generate blockies (e.g. Ethereum wallet address)

[output-fmt] - ansi (Default) Generate ansi sequence of blockies, usually for printing to terminal - image Generate png image data of blockies

[OPTIONS...]:

    -e --ethseed   Interpret seed string as Ethereum address,
                   and canonicalize seed (to lowercase + set '0x' prefix)
                   to get Ethereum blockies correctly
    -a --ascii     (only for 'ansi' mode)   Get non-compact, big blockies
                                            with ascii (non-unicode)
    -r --raw       (only for 'image' mode)  Get uncompressed, raw png image

    -s --size=<BLOCKIES_SIZE>
                   Blockies size: # of elems per side (1-32) (Default: '8')

    -d --dimension=<WIDTH>x<HEIGHT>
                   Dimensions of output in the form of '(width)x(height)'
                   If not given, following is used (Default):
                   - ('ansi' mode)   '(blockies_size)x(blockies_size)'
                   - ('image' mode)  '128x128'

    -o --outfile=<FILENAME>
                   File name to write output
                   If the parameter is not given, stdout is used (Default)

examples:

Author

Kim Hwiwon \

License

The MIT License (MIT)