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;

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.
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.
NoTransfer
Identity transfer function: no conversion.
Pipeline
Builder for image processing pipelines.
PixelDescriptor
Compact pixel format descriptor.
Pq
SMPTE ST 2084 (PQ) transfer function for HDR10 content.
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.
Size
Width × height dimensions in pixels.
Srgb
sRGB transfer function.
StreamingResize
Streaming resize state machine.

Enums§

AlphaMode
Alpha channel interpretation.
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.
Orientation
Image orientation as an element of the D4 dihedral group.
SourceCrop
Region of source image to use before applying the constraint.
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.
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.
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.
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.