Skip to content
Simple resampling library in pure Rust
Rust
Branch: master
Clone or download
Latest commit 5488aab Mar 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benches Support 16-bit formats Apr 4, 2017
examples Remove comparision with IM Apr 21, 2017
scripts Add travis.yml and API docs generation Nov 3, 2015
src Comment fixes Apr 22, 2017
.gitignore Remove comparision with IM Apr 21, 2017
.travis.yml Add travis.yml and API docs generation Nov 3, 2015
Cargo.toml Bump png to 0.14 Mar 17, 2019
LICENSE Initial commit Nov 3, 2015
README.md Remove comparision with IM Apr 21, 2017

README.md

resize Build Status crates.io

Simple resampling library in pure Rust.

Features

  • No dependencies, minimal abstractions
  • No encoders/decoders, meant to be used with some external library
  • Tuned for resizing to the same dimensions multiple times: uses preallocated buffers and matrixes

Usage

extern crate resize;
use resize::Pixel::RGB24;
use resize::Type::Lanczos3;

// Downscale by 2x.
let (w1, h1) = (640, 480);
let (w2, h2) = (320, 240);
// Don't forget to fill `src` with image data (RGB24).
let src = vec![0;w1*h1*3];
// Destination buffer. Must be mutable.
let mut dst = vec![0;w2*h2*3];
// Create reusable instance.
let mut resizer = resize::new(w1, h1, w2, h2, RGB24, Lanczos3);
// Do resize without heap allocations.
// Might be executed multiple times for different `src` or `dst`.
resizer.resize(&src, &mut dst);

See API documentation for overview of all available methods. See also this example.

Recommendations

Read this and this great articles on image resizing technics and resampling filters. Tldr; (with built-in filters of this library) use Lanczos3 for downscaling, use Mitchell for upscaling. You may also want to downscale in linear colorspace (but not upscale). Gamma correction routines currently not included to the library, but actually quite simple to accomplish manually, see here for some basic theory.

License

  • Library is licensed under MIT
  • Image used in examples is licensed under CC BY-SA 3.0
You can’t perform that action at this time.