ImageOptimizerOptions

Structin image_optimizerfastly 0.13.1View source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#[non_exhaustive]
pub struct ImageOptimizerOptions {
pub preserve_query_string_on_origin_request: Option<bool>,
pub allow_malformed_query_params: Option<bool>,
pub auto: Option<Auto>,
pub bg_color: Option<HexColor>,
pub blur: Option<BlurMode>,
pub brightness: Option<i32>,
pub bw: Option<BWMode>,
pub canvas: Option<Canvas>,
pub contrast: Option<i32>,
pub crop: Option<Crop>,
pub dpr: Option<f32>,
pub enable: Option<EnableOpt>,
pub fit: Option<Fit>,
pub format: Option<Format>,
pub frame: Option<u32>,
pub height: Option<PixelsOrPercentage>,
pub level: Option<Level>,
pub metadata: Option<Metadata>,
pub optimize: Option<OptimizeLevel>,
pub orient: Option<Orientation>,
pub pad: Option<Sides>,
pub precrop: Option<Crop>,
pub profile: Option<Profile>,
pub quality: Option<u32>,
pub resize_filter: Option<ResizeAlgorithm>,
pub saturation: Option<i32>,
pub sharpen: Option<Sharpen>,
pub trim: Option<Sides>,
pub trim_color: Option<TrimColor>,
}

ImageOptimizerOptions contains options that correspond to the public API.

Fields

Indicates where image transformations will occur. Must be set.

See ImageOptimizerRegion for available options. The chosen region should be close to your origin.

preserve_query_string_on_origin_request

Option<bool>

If true, preserves query parameters not belonging to the Image Optimizer API when requesting the origin image.

allow_malformed_query_params

Option<bool>

If true, ignores malformed and duplicate query parameters and returns a response header, Fastly-Io-Compute-Warnings, containing a comma separated list of errors (if there are any).

By default IO on compute is strict when parsing query parameters, and passing an invalid or malformed value produces an HTTP 400 response. This behavior is different than IO running in VCL services where most errors fail silently. Setting this parameter to true should make the behavior more in line with VCL services.

Requests an output format based on the Accept header.

bg_color

Option<HexColor>

Sets a background color when replacing transparent pixels or with pad or canvas.

Blurs the image.

brightness

Option<i32>

Adjusts image brightness.

Converts image to black and white duotone.

canvas

Option<Canvas>

Adds a canvas surrounding the image.

contrast

Option<i32>

Adjusts image contrast.

Crops the image.

dpr

Option<f32>

Ratio between physical and logical pixels, a float between 0-10.

Adjusts any resize requests according to this ratio.

Allows for various image transformations to occur, particularly upscaling images.

Describes how the image should fit within the requested dimensions.

format

Option<Format>

Re-encodes the image to a given output format.

frame

Option<u32>

Request a single frame for an animated image.

Currently only supported for animated GIFs.

Adjusts image height.

For use with GIF to MP4 conversions.

See https://www.fastly.com/documentation/reference/io/level/ for detailed information.

metadata

Option<Metadata>

Preserves metadata on the input image.

Attempts to select an output quality to optimize the image.

Controls how the image will be oriented.

Adds pixels surrounding the image.

precrop

Option<Crop>

Applies the crop instruction before all other parameters.

profile

Option<Profile>

For use with GIF to MP4 conversions.

See https://www.fastly.com/documentation/reference/io/level/ for detailed information.

quality

Option<u32>

Request an output quality.

resize_filter

Option<ResizeAlgorithm>

Specify which algorithm to use when resizing an image.

saturation

Option<i32>

Adjust image saturation.

sharpen

Option<Sharpen>

Applies an unsharp mask to the image.

Removes pixels from the image on all sides.

trim_color

Option<TrimColor>

Trims the image on all sides based on a given color.

Adjusts image width.

Methods

from_region

View source
fn from_region(region: ImageOptimizerRegion) -> Self

Create ImageOptimizerOptions for the specified region. It is recommended to pick a region closest to your origin that serves images.

See Request::set_image_optimizer for example usage.

Parameters

region: ImageOptimizerRegion

Returns

Self

Trait implementations

impl Clone for ImageOptimizerOptions

fn clone(&self) -> Self

Parameters

self: &Self

Returns

Self

impl Debug for ImageOptimizerOptions

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

Parameters

self: &Self
f: &mut $crate::fmt::Formatter

Returns

$crate::fmt::Result

impl Default for ImageOptimizerOptions

fn default() -> Self

Returns

Self

impl Serialize for ImageOptimizerOptions

serialize

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

Parameters

self: &Self
__serializer: __S

Returns

_serde::__private228::Result<__S::Ok, __S::Error>

Auto trait implementations

Blanket implementations