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
impl Clone for ResizeConfig
Source§fn clone(&self) -> ResizeConfig
fn clone(&self) -> ResizeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more