Skip to main content

Crate zenresize

Crate zenresize 

Source
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;
pub use composite::composite_over_premul;
pub use composite::composite_over_solid_opaque_premul;
pub use composite::composite_over_solid_premul;
pub use composite::unpremultiply_f32_row;

Modules§

composite
Compositing for blending resized images onto backgrounds.
layout
Layout constraint computation and pipeline planning for resize operations.
plane
Single-plane i16 image resizer.

Structs§

At
An error with location tracking - wraps any error type.
Bt709
BT.709 transfer function (also used for BT.601).
Constraint
Layout constraint specification.
DecoderOffer
What the decoder actually did.
DecoderRequest
What the layout engine wants the decoder to do.
Hlg
HLG (Hybrid Log-Gamma) transfer function for broadcast HDR.
IdealLayout
Result of the first phase of layout planning.
Layout
Computed layout from applying a Constraint to source dimensions.
LayoutPlan
Final layout plan after decoder negotiation.
LinearGradientMask
Linear gradient mask.
MaskSpan
A contiguous horizontal span with uniform mask behavior.
MaskSpans
Inline collection of mask spans for one row.
NoTransfer
Identity transfer function: no conversion.
Padding
Padding to add around the resized output.
Pipeline
Builder for image processing pipelines.
PixelDescriptor
Compact pixel format descriptor.
Pq
SMPTE ST 2084 (PQ) transfer function for HDR10 content.
RadialGradientMask
Radial gradient mask.
Rect
Axis-aligned rectangle in pixel coordinates.
ResizeConfig
Resize configuration built with ResizeConfigBuilder.
ResizeConfigBuilder
Builder for ResizeConfig.
Resizer
Reusable resizer with pre-computed weight tables.
RoundedRectMask
Antialiased rounded rectangle mask.
Size
Width × height dimensions in pixels.
SourceRegion
Region of the source image to use for resizing.
Srgb
sRGB transfer function.
StreamingResize
Streaming resize state machine.

Enums§

AlphaMode
Alpha channel interpretation.
BlendMode
Porter-Duff and artistic blend modes.
CanvasColor
Canvas background color for pad modes.
ChannelLayout
Channel layout (number and meaning of channels).
ChannelType
Channel storage type.
ConstraintMode
How to fit a source image into target dimensions.
Filter
Named interpolation filter presets.
Gravity
Where to position the image when cropping or padding.
LayoutError
Layout computation error.
LobeRatio
Negative-lobe ratio control for resampling weights.
MaskFill
Result of filling a mask row. Enables skipping work on uniform rows.
OrientOutput
Post-resize orientation transform.
Orientation
Image orientation as an element of the D4 dihedral group.
SourceCrop
Region of source image to use before applying the constraint.
SpanKind
What kind of pixels a span contains.
StreamingError
Errors from streaming resize push operations.
TransferFunction
Electro-optical transfer function.
WorkingFormat
The internal working format of the streaming resizer.

Traits§

Element
Pixel element type.
MaskSource
Row-level mask generator.
ResultAtExt
Extension trait for adding location tracking to Result<T, At<E>>.
TransferCurve
Transfer function for encoding/decoding pixel values to/from linear light.

Functions§

canvas_color_to_pixel
Convert a CanvasColor to pixel bytes for the given descriptor.
config_from_plan
Build a [ResizeConfig] from a LayoutPlan with crop and padding.
execute
Execute an IdealLayout assuming full decode (no decoder negotiation).
execute_layout
Execute a finalized LayoutPlan on decoder output.
execute_layout_with_background
Execute a LayoutPlan with 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 IdealLayout with background compositing, assuming full decode.
execute_with_offer
Execute an IdealLayout with a real DecoderOffer (decoder negotiation).
fill_canvas
Fill a canvas buffer with a repeated pixel value.
mask_pixel_align
Preferred pixel alignment for mask span boundaries on the current platform.
orient_image
Apply an Orientation transform 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 the rgb crate).
resize_gray8
Resize a grayscale u8 image.
resize_hfirst_streaming
H-first streaming resize for sRGB u8 4ch.
resize_hfirst_streaming_f32
H-first streaming resize for the f32 path (any channel count).
streaming_from_plan
Create a crate::StreamingResize from a LayoutPlan.
streaming_from_plan_batched
Like streaming_from_plan() but with a batch hint for the ring buffer.