#image #compression #qoi #cli #pixlzr

bin+lib pixlzr

Pixlzr - A rust lib and CLI for the pixlzr image format

5 releases

new 0.2.2 Mar 16, 2023
0.2.1 Jan 11, 2023
0.2.0 Jan 11, 2023
0.1.1 Oct 7, 2022
0.1.0 Oct 7, 2022

#94 in Compression

22 downloads per month

Custom license


A lossy image compression algorithm, based in a per-block level of detail detection, implemented in Rust.


Crate downloads Crate recent downloads Crate version Last GitHub commit


Just put pixlzr = "0" as one of the [dependencies] into your Cargo.toml.


Before using it

Now, the crate pixlzr have two parallel APIs, with different uses and functionalities.

The base use, of reducing / shrinking a crate image::DynamicImage, is present in both. But in the future, the old API will be either deleted or rewritten based on the new one, which supports file saving / readding.

Using the old API

use image::{open, DynamicImage};
use pixlzr::process::{
        process as tree_process,
        full as tree_full_process

// ...

let image: DynamicImage = open("img.png")?;

process(&image, 64, Some(|v| v / 4.0)): DynamicImage

tree_process(&image, 64, 0.25, Some(|v| v / 6.0)): DynamicImage

tree_full_process(&image, 0.25, Some(|v| v / 6.0)): DynamicImage

Using the new API

// Importing
use image::{open, DynamicImage};
use pixlzr::{FilterType, Pixlzr};
// Convert to
let png: DynamicImage = open("img.png");

let mut pix = Pixlzr::from_image(&img, 64, 64u32);
pix.shrink_by(FilterType::Gaussian, 0.8);

pix.save("pix-lized image.pixlzr")?;
// Convert from
let pix = Pixlzr::open("pix-lized image.pixlzr")?;
let img = pix.to_image(FilterType::Nearest)?;


The CLI can be understood with a run of pixlzr -h.

Pixlzr - A rust lib and CLI for the pixlzr image format

Usage: pixlzr [OPTIONS] --input <INPUT> --output <OUTPUT>

  -i, --input <INPUT>                The input image file
  -o, --output <OUTPUT>              The output image file
  -b, --block-width <BLOCK_WIDTH>    The width of each block [default: 64]
      --block-height <BLOCK_HEIGHT>  The height of each block
  -k, --shrink-by <SHRINK_BY>        The shrinking factor [default: 1]
      --filter <FILTER>              The filter used when resizing the image blocks [default: lanczos3] [possible values: nearest, triangle, catmull-rom, gaussian, lanczos3]
  -h, --help                         Print help (see more with '--help')
  -V, --version                      Print version

It converts from and to the pixlzr format, with use of the crate image.

Core concept

Yet to be written...
Please check GitHub:guiga-zalu/smart-pixelizer, as it's the implementation in Node JS.


~183K SLoC