7 releases

0.5.0-rc0 Apr 26, 2024
0.4.15 Feb 17, 2024
0.4.14 Jan 15, 2024
0.4.13 Dec 12, 2023
0.4.11 Nov 17, 2023

#821 in Images

Download history 47/week @ 2024-07-22 76/week @ 2024-07-29 46/week @ 2024-08-05 66/week @ 2024-08-12 28/week @ 2024-08-19 127/week @ 2024-08-26 105/week @ 2024-09-02 26/week @ 2024-09-09 54/week @ 2024-09-16 137/week @ 2024-09-23 109/week @ 2024-09-30 92/week @ 2024-10-07 25/week @ 2024-10-14 54/week @ 2024-10-21 74/week @ 2024-10-28 26/week @ 2024-11-04

224 downloads per month
Used in blade-render

MIT OR Apache-2.0 OR Zlib

705KB
13K SLoC

zune-imageprocs

A library for low level image processing routines

They work on raw pixels (T) and they are focused on speed and safety.

Warning

Some filters are in alpha stage, and some are broken, don't use a filter with a Broken tag

Usage

Add the crate to your dependencies e.g cargo add zune-imageprocs

After that one can use the processing routines since they implement zune-image OperationsTrait, anywhere that supports them can call on them

E.g. to increase the exposure of an image

use zune_core::colorspace::ColorSpace;
use zune_image::errors::ImageErrors;
use zune_image::image::Image;
use zune_image::traits::OperationsTrait;
use zune_imageprocs::exposure::Exposure;

fn main()->Result<(),ImageErrors> {
    // create a 100x100 grayscale image
    let mut img = Image::from_fn::<u16, _>(100, 100, ColorSpace::Luma, |x, y, pix| {
        pix[0] = ((x + y) % 65536) as u16;
    });
    // increase each pixels strength by 2
    Exposure::new(2.0, 0.0).execute(&mut img)?;
    // write to a file
    img.save("hello.png")?;
}

Features

  • portable-simd: This adds support for portable simd, requires a nightly compiler. Some routines are written in portable simd and hence this can speed up some computations.

    • Disabled by default
  • threads: Adds support for multithreading on image filters, some filters can run independently per channel, especially computational heavy filters, this enables that. On platforms without multithtreading (e.g wasm), this should be disabled

    • Enabled by default

Benchmarking

Most routines in the library can be benchmarked, but they require a nightly compiler

To test speed of most routines run

cargo bench --features=benchmarks

Dependencies