22 releases (2 stable)

Uses new Rust 2024

1.0.1 Jun 18, 2026
0.15.0 Apr 15, 2026
0.14.0 Mar 15, 2025
0.13.4 Oct 24, 2024
0.6.1 Jul 28, 2019

#185 in Images

Download history 71993/week @ 2026-04-22 69269/week @ 2026-04-29 23774/week @ 2026-05-06 21922/week @ 2026-05-13 25716/week @ 2026-05-20 21217/week @ 2026-05-27 30816/week @ 2026-06-03 39277/week @ 2026-06-10 35508/week @ 2026-06-17 33170/week @ 2026-06-24 35644/week @ 2026-07-01 42489/week @ 2026-07-08 40839/week @ 2026-07-15 44384/week @ 2026-07-22 67898/week @ 2026-07-29 82455/week @ 2026-08-05

243,768 downloads per month
Used in 38 crates (13 directly)

MIT/Apache

200KB
3.5K SLoC

pix

Library for image conversion and compositing.

A raster image can be cheaply converted to and from raw byte buffers, enabling interoperability with other crates.

Many image formats are supported:

  • Bit depth: 8- or 16-bit integer and 32-bit float
  • Alpha: premultiplied or straight
  • Gamma: linear or sRGB
  • Color models:
    • RGB / BGR (red, green, blue)
    • CMY (cyan, magenta, yellow)
    • Gray (luma / relative luminance)
    • HSV (hue, saturation, value)
    • HSL (hue, saturation, lightness)
    • HWB (hue, whiteness, blackness)
    • YCbCr (used by JPEG)
    • Matte (alpha only)
    • OkLab (lightness, green/red, blue/yellow)
    • XYZ (CIE 1931 XYZ)

HWB Color Example

use pix::{hwb::SHwb8, rgb::SRgb8, Raster};

let mut r = Raster::with_clear(256, 256);
for (y, row) in r.rows_mut(()).enumerate() {
    for (x, p) in row.iter_mut().enumerate() {
        let h = ((x + y) >> 1) as u8;
        let w = y.saturating_sub(x) as u8;
        let b = x.saturating_sub(y) as u8;
        *p = SHwb8::new(h, w, b);
    }
}
// Convert to SRgb8 color model
let raster = Raster::<SRgb8>::with_raster(&r);

Colors

Compositing Example

Compositing is supported for premultiplied images with linear gamma.

use pix::{ops::SrcOver, rgb::Rgba8p, Raster};

let mut r0 = Raster::with_clear(100, 100);
let r1 = Raster::with_color(5, 5, Rgba8p::new(80, 0, 80, 200));
r0.composite_raster((40, 40), &r1, (), SrcOver);

Documentation

https://docs.rs/pix

No runtime deps