resize 0.2.0

Simple resampling library in pure Rust.
Documentation

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
  • Tuned to have result as close as possible to ImageMagick (Q16 HDRI)

Usage

extern crate resize;
use resize::Pixel::Gray8;
use resize::Type::Triangle;
let mut src = vec![0;w1*h1];
let mut dst = vec![0;w2*h2];
let mut resizer = resize::new(w1, h1, w2, h2, Gray8, Triangle);
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.

Triangle test

Comparision of libswscale (4.0.100) with IM (6.9.2.0 Q16 HDRI):

cd examples
convert tiger.png -filter Triangle -resize 540x360 im.png
ffmpeg -i tiger.png -vf scale=540:360:flags=bilinear sws.png
compare sws.png im.png -compose src diff-sws-im.png

Comparision of this library (0.1.0) with IM (6.9.2.0 Q16 HDRI):

../target/debug/examples/resize tiger.png 540x360 rust.png
compare rust.png im.png -compose src diff-rust-im.png

License

  • Library is licensed under MIT
  • Image used in examples is licensed under CC BY-SA 3.0