fast_image_resize
SIMD-accelerated Rust library for fast image resizing across pixel formats
Repository Health
Technical Analysis
fast_image_resize is a Rust crate for resizing images quickly by using hand-written SIMD code paths for SSE4.1, AVX2, ARM Neon, and WebAssembly SIMD128, falling back to portable scalar code on unsupported CPUs. It supports a wide range of pixel formats — 8-bit and 16-bit images with 1 to 4 components, plus 32-bit float and integer single-component formats — covering common layouts like L, LA, RGB, RGBA, RGBx, and CMYK.
The library exposes multiple resize algorithms (nearest, convolution-based with selectable filters, interpolation, and supersampling), optional alpha premultiplication handling, cropping/fit-into-destination source options, and optional multithreading via Rayon. It is designed to be embedded in higher-level image pipelines (its own benchmarks compare it against the image and other Rust resizing crates) rather than used as a standalone CLI tool.
What You Get
- Hand-written SIMD implementations for SSE4.1, AVX2, ARM Neon, and Wasm32 SIMD128, with automatic CPU-feature detection and scalar fallback
- Support for U8/U8x2/U8x3/U8x4, U16 variants, I32, and F32 pixel formats covering L, LA, RGB(x), RGBA, and CMYK-style layouts
- Multiple resize algorithms — Nearest, Convolution (with filter selection such as Lanczos3), Interpolation, and SuperSampling
- Cropping and fit-into-destination source options plus configurable alpha premultiplication handling during resize
- Optional integration with the
imagecrate’s image types and optional Rayon-based multithreaded resizing no_std-capable core with an optionalstdfeature flag for use in constrained environments
Common Use Cases
- Server-side thumbnail and preview generation in a Rust image-processing or media pipeline
- Resizing images at high throughput where the standard
imagecrate’s built-in resize is a bottleneck - Client-side or edge image resizing compiled to WebAssembly for in-browser processing
- Batch image pipelines needing precise control over pixel format (16-bit, float, CMYK) during resize, not just 8-bit RGB
Under The Hood
Architecture - The crate centers on a Resizer (src/resizer.rs) that dispatches to per-format convolution/interpolation code in src/convolution, with pixel-format abstractions in src/pixels.rs and src/image_view.rs providing ImageView/ImageViewMut traits so callers can resize into their own buffer types rather than being locked to one image type. CPU feature detection (src/cpu_extensions.rs, cpufeatures crate) selects between SSE4.1, AVX2, Neon, and scalar code paths at runtime, while a separate wasm32_utils.rs handles the Wasm SIMD128 path at compile time. Tech Stack - Pure Rust, no_std-capable by default with an opt-in std feature; optional dependencies include image (for interop with the popular image crate’s types), bytemuck (safe transmutes for SIMD buffers), rayon (multithreaded resizing), and document-features for feature-flag docs; a companion resizer workspace member and benches/ directory hold example/benchmark code comparing against other Rust resize crates. Code Quality - Tests exist in both a tests/ directory (6 files) and inline in a couple of source modules; the crate uses #[non_exhaustive] on public enums (ResizeAlg, SrcCropping) to allow adding variants without a breaking change, and thiserror (with a no_std-compatible mode) for typed errors like DifferentDimensionsError/ResizeError. Benchmarks are tracked per-architecture (benchmarks-x86_64.md, benchmarks-arm64.md, benchmarks-wasm32.md), suggesting performance regressions are actively monitored. API Design - The public surface centers on a small set of types (Resizer, ResizeOptions, ResizeAlg, CropBox) with sensible defaults (ResizeAlg::Convolution(FilterType::Lanczos3)), so a basic resize needs only a few lines, while the format/algorithm generics allow precise control when needed.
Used by 2 apps in this directory
DevTools-X
Developer Tools
41 offline-first developer utilities in a single 10MB cross-platform desktop app — no Electron, no cloud, no compromise.
Fyrox
Game Development
A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts