Expand description
High-quality image resampling with 31 filters, streaming API, and SIMD acceleration.
zenresize provides a standalone resize library extracted from the zenimage/imageflow
image processing pipeline. It supports:
- All 31 resampling filters from imageflow (Lanczos, Robidoux, Mitchell, etc.)
- Row-at-a-time streaming API with V-first pipeline for pipeline integration
- Built-in sRGB/linear conversion and alpha premultiply/unpremultiply
- u8, i16, and f32 pixel format support
- archmage-based SIMD (AVX2+FMA on x86, NEON on ARM)
§Quick Start
use zenresize::{Resizer, ResizeConfig, Filter, PixelDescriptor};
// Create a 4×4 RGBA test image
let input_pixels = vec![128u8; 4 * 4 * 4];
let config = ResizeConfig::builder(4, 4, 2, 2)
.filter(Filter::Lanczos)
.format(PixelDescriptor::RGBA8_SRGB)
.build();
let output = Resizer::new(&config).resize(&input_pixels);
assert_eq!(output.len(), 2 * 2 * 4);Re-exports§
pub use plane::PlaneResizer;pub use composite::Background;pub use composite::CompositeError;pub use composite::NoBackground;pub use composite::SliceBackground;pub use composite::SolidBackground;pub use composite::StreamedBackground;
Modules§
- composite
- Porter-Duff source-over compositing for blending resized images onto backgrounds.
- layout
- Layout constraint computation and pipeline planning for resize operations.
- plane
- Single-plane i16 image resizer.
Structs§
- Bt709
- BT.709 transfer function (also used for BT.601).
- Constraint
- Layout constraint specification.
- Decoder
Offer - What the decoder actually did.
- Decoder
Request - What the layout engine wants the decoder to do.
- Hlg
- HLG (Hybrid Log-Gamma) transfer function for broadcast HDR.
- Ideal
Layout - Result of the first phase of layout planning.
- Layout
- Computed layout from applying a
Constraintto source dimensions. - Layout
Plan - Final layout plan after decoder negotiation.
- NoTransfer
- Identity transfer function: no conversion.
- Pipeline
- Builder for image processing pipelines.
- Pixel
Descriptor - Compact pixel format descriptor.
- Pq
- SMPTE ST 2084 (PQ) transfer function for HDR10 content.
- Rect
- Axis-aligned rectangle in pixel coordinates.
- Resize
Config - Resize configuration built with
ResizeConfigBuilder. - Resize
Config Builder - Builder for
ResizeConfig. - Resizer
- Reusable resizer with pre-computed weight tables.
- Size
- Width × height dimensions in pixels.
- Srgb
- sRGB transfer function.
- Streaming
Resize - Streaming resize state machine.
Enums§
- Alpha
Mode - Alpha channel interpretation.
- Canvas
Color - Canvas background color for pad modes.
- Channel
Layout - Channel layout (number and meaning of channels).
- Channel
Type - Channel storage type.
- Constraint
Mode - How to fit a source image into target dimensions.
- Filter
- Named interpolation filter presets.
- Gravity
- Where to position the image when cropping or padding.
- Layout
Error - Layout computation error.
- Lobe
Ratio - Negative-lobe ratio control for resampling weights.
- Orientation
- Image orientation as an element of the D4 dihedral group.
- Source
Crop - Region of source image to use before applying the constraint.
- Streaming
Error - Errors from streaming resize push operations.
- Transfer
Function - Electro-optical transfer function.
- Working
Format - The internal working format of the streaming resizer.
Traits§
- Element
- Pixel element type.
- Transfer
Curve - Transfer function for encoding/decoding pixel values to/from linear light.
Functions§
- canvas_
color_ to_ pixel - Convert a
CanvasColorto pixel bytes for the given descriptor. - execute
- Execute an
IdealLayoutassuming full decode (no decoder negotiation). - execute_
layout - Execute a finalized
LayoutPlanon decoder output. - execute_
layout_ with_ background - Execute a
LayoutPlanwith background compositing. - execute_
secondary - Convenience: derive and execute a secondary plane assuming full decode.
- execute_
secondary_ with_ background - Convenience: derive and execute a secondary plane with background compositing.
- execute_
with_ background - Execute an
IdealLayoutwith background compositing, assuming full decode. - execute_
with_ offer - Execute an
IdealLayoutwith a realDecoderOffer(decoder negotiation). - fill_
canvas - Fill a canvas buffer with a repeated pixel value.
- orient_
image - Apply an
Orientationtransform to an image buffer. - place_
on_ canvas - Blit an image onto a canvas at the given placement offset.
- replicate_
edges - Replicate right and bottom edges for MCU alignment padding.
- resize_
3ch - Resize a 3-channel u8 image. Works with
rgb::RGB<u8>,rgb::BGR<u8>, etc. - resize_
4ch - Resize a 4-channel u8 image. Works with any pixel type that implements
ComponentSlice(RGBA, BGRA, ARGB, ABGR from thergbcrate). - resize_
gray8 - Resize a grayscale u8 image.