ResizeConfig

Struct ResizeConfig 

Source
pub struct ResizeConfig {
Show 24 fields pub anim: Option<bool>, pub background: Option<String>, pub blur: Option<u8>, pub border: Option<ResizeBorder>, pub brightness: Option<f64>, pub compression: Option<ResizeCompression>, pub contrast: Option<f64>, pub dpr: Option<f64>, pub draw: Option<ResizeDraw>, pub fit: Option<ResizeFit>, pub flip: Option<ResizeFlip>, pub format: Option<ResizeFormat>, pub gamma: Option<f64>, pub gravity: Option<ResizeGravity>, pub height: Option<usize>, pub metadata: Option<ResizeMetadata>, pub origin_auth: Option<ResizeOriginAuth>, pub onerror: Option<ResizeOnerror>, pub quality: Option<ResizeQuality>, pub rotate: Option<usize>, pub saturation: Option<f64>, pub sharpen: Option<f64>, pub trim: Option<ResizeTrim>, pub width: Option<usize>,
}
Expand description

Configuration options for Cloudflare’s image resizing feature: https://developers.cloudflare.com/images/image-resizing/

Fields§

§anim: Option<bool>

Whether to preserve animation frames from input files. Default is true. Setting it to false reduces animations to still images.

§background: Option<String>

Background color to add underneath the image. Applies to images with transparency (for example, PNG) and images resized with fit=pad.

§blur: Option<u8>

Blur radius between 1 (slight blur) and 250 (maximum). Be aware that you cannot use this option to reliably obscure image content.

§border: Option<ResizeBorder>

Adds a border around the image. The border is added after resizing.

§brightness: Option<f64>

Increase brightness by a factor. A value of 1.0 equals no change, a value of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.

§compression: Option<ResizeCompression>

Slightly reduces latency on a cache miss by selecting a quickest-to-compress file format, at a cost of increased file size and lower image quality.

§contrast: Option<f64>

Increase contrast by a factor. A value of 1.0 equals no change, a value of 0.5 equals low contrast, and a value of 2.0 equals high contrast.

§dpr: Option<f64>

Device Pixel Ratio. Default is 1. Multiplier for width/height that makes it easier to specify higher-DPI sizes in <img srcset>.

§draw: Option<ResizeDraw>

Drawing operations to overlay on the image.

§fit: Option<ResizeFit>

Affects interpretation of width and height. All resizing modes preserve aspect ratio.

§flip: Option<ResizeFlip>

Flips the image horizontally, vertically, or both. Can be used with the rotate parameter to set the orientation of an image.

§format: Option<ResizeFormat>

The auto option will serve the WebP or AVIF format to browsers that support it. If this option is not specified, a standard format like JPEG or PNG will be used.

§gamma: Option<f64>

Increase exposure by a factor. A value of 1.0 equals no change, a value of 0.5 darkens the image, and a value of 2.0 lightens the image.

§gravity: Option<ResizeGravity>

Specifies how an image should be cropped when used with fit=cover and fit=crop. Available options are auto, face, a side (left, right, top, bottom), and relative coordinates (XxY with a valid range of 0.0 to 1.0).

§height: Option<usize>

Specifies maximum height of the image in pixels. Exact behavior depends on the fit mode (described below).

§metadata: Option<ResizeMetadata>

Controls amount of invisible metadata (EXIF data) that should be preserved. Color profiles and EXIF rotation are applied to the image even if the metadata is discarded.

§origin_auth: Option<ResizeOriginAuth>

Authentication method for accessing the origin image.

§onerror: Option<ResizeOnerror>

In case of a fatal error that prevents the image from being resized, redirects to the unresized source image URL. This may be useful in case some images require user authentication and cannot be fetched anonymously via Worker.

§quality: Option<ResizeQuality>

Specifies quality for images in JPEG, WebP, and AVIF formats. The quality is in a 1-100 scale, but useful values are between 50 (low quality, small file size) and 90 (high quality, large file size).

§rotate: Option<usize>

Number of degrees (90, 180, or 270) to rotate the image by. width and height options refer to axes after rotation.

§saturation: Option<f64>

Increases saturation by a factor. A value of 1.0 equals no change, a value of 0.5 equals half saturation, and a value of 2.0 equals twice as saturated.

§sharpen: Option<f64>

Specifies strength of sharpening filter to apply to the image. The value is a floating-point number between 0 (no sharpening, default) and 10 (maximum).

§trim: Option<ResizeTrim>

Specifies a number of pixels to cut off on each side. Allows removal of borders or cutting out a specific fragment of an image.

§width: Option<usize>

Specifies maximum width of the image. Exact behavior depends on the fit mode; use the fit=scale-down option to ensure that the image will not be enlarged unnecessarily.

Trait Implementations§

Source§

impl Clone for ResizeConfig

Source§

fn clone(&self) -> ResizeConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResizeConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ResizeConfig

Source§

fn default() -> ResizeConfig

Returns the “default value” for a type. Read more
Source§

impl Serialize for ResizeConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToRawKvValue for T
where T: Serialize,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,