pub enum OutputResolution {
Original,
Width2560,
Width1080,
Custom(u32),
}Expand description
Controls the output resolution applied before AVIF encoding.
Set this on Config via
Config::output_resolutions to
produce one or more outputs at different sizes from a single decode pass.
§Downscale-only
When the decoded image is already at or below the target width the
pixels are passed through unchanged — img4avif never upscales.
§Aspect ratio
The height is always scaled proportionally so the image is never cropped or distorted.
§Example
use img4avif::{Config, Converter, OutputResolution};
// Produce only the 1080-wide variant.
let config = Config::default()
.output_resolutions(vec![OutputResolution::Width1080]);
let converter = Converter::new(config)?;
let avif_1080 = converter.convert(&std::fs::read("photo.jpg")?)?;
std::fs::write("photo_1080.avif", avif_1080)?;Variants§
Original
Preserve the original image dimensions (no resize).
Width2560
Shrink so the width is at most 2560 pixels, preserving the aspect ratio. Images already ≤ 2560 px wide are passed through unchanged.
Width1080
Shrink so the width is at most 1080 pixels, preserving the aspect ratio. Images already ≤ 1080 px wide are passed through unchanged.
Custom(u32)
Shrink so the width is at most the given number of pixels, preserving the aspect ratio. Images already at or below this width are passed through unchanged.
A width of 0 is treated the same as Original —
the image is returned at its full size without any resizing. This is
a deliberate design choice that makes it safe to derive a target width
from arithmetic that could produce zero; callers that want a hard error
on zero should validate the value before constructing this variant.
Trait Implementations§
Source§impl Clone for OutputResolution
impl Clone for OutputResolution
Source§fn clone(&self) -> OutputResolution
fn clone(&self) -> OutputResolution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputResolution
impl Debug for OutputResolution
Source§impl Hash for OutputResolution
impl Hash for OutputResolution
Source§impl PartialEq for OutputResolution
impl PartialEq for OutputResolution
impl Copy for OutputResolution
impl Eq for OutputResolution
impl StructuralPartialEq for OutputResolution
Auto Trait Implementations§
impl Freeze for OutputResolution
impl RefUnwindSafe for OutputResolution
impl Send for OutputResolution
impl Sync for OutputResolution
impl Unpin for OutputResolution
impl UnsafeUnpin for OutputResolution
impl UnwindSafe for OutputResolution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more