Skip to main content

Crate media_kit

Crate media_kit 

Source
Expand description

Full image pipeline — sniff, meta, resize, encode, composite, variants with bomb-guard, EXIF auto-orientation, parallel variant fan-out and async support.

This crate is std-only (the image decoder stack requires std).

§Example

use media_kit::pipeline::Pipeline;
use media_kit::resize::{Fit, Filter};
use media_kit::encode::OutFormat;

let jpeg = media_kit::testutil::tiny_jpeg();
let out = Pipeline::new(OutFormat::WebP(None))
    .resize(Fit::MaxSide(200), Filter::Lanczos3)
    .run(&jpeg)?;
assert!(!out.is_empty());

§Variants (decode once, fan out in parallel)

use media_kit::variants::{Variant, VariantSet};
use media_kit::resize::Fit;
use media_kit::encode::OutFormat;

let set = VariantSet::new()
    .with(Variant::new("thumb", Fit::MaxSide(200), OutFormat::WebP(None)))
    .with(Variant::new("medium", Fit::Width(800), OutFormat::Jpeg(85)));
// sniffs, bomb-guards, decodes once, auto-orients, fans out
let outs = set.generate_from_bytes(&media_kit::testutil::tiny_jpeg())?;
assert_eq!(outs.len(), 2);

Re-exports§

pub use error::MediaError;

Modules§

composite
Layering, watermarks, and alpha flattening.
encode
Output encoding for supported formats.
error
Error type for the whole pipeline.
exif
EXIF metadata extraction and orientation handling (behind the exif feature).
meta
Header-only metadata inspection and decompression-bomb guards.
pipeline
High-level decode -> transform -> encode pipeline with bomb-guarding.
resize
Aspect-preserving and cover-fit resizing.
sniff
Magic-byte format sniffing — zero dependencies, no decoding.
testutil
Sample media used by doctests, integration tests, and benches. Shared sample media for doctests, unit tests, and benches.
variants
Multi-size output generation (“thumb”, “medium”, “large”, …).