Image Resizer : API Documentation

Type ResizeSettings

Namespace ImageResizer

Parent QuerystringBase<TK>

Represents the settings which will be used to process the image. Extends NameValueCollection to provide friendly property names for commonly used settings. Replaced by the Instructions class. Will be removed in V4.0

Methods

Properties

Public instance methods

RectangleF getCustomCropSourceRect(SizeF imageSize)

void Normalize()

This method will 'normalize' command aliases to the primary key name and resolve duplicates. w->width, h->height, sourceFlip->sFlip, thumbnail->format

ResizeSettings Normalize(string primary, string secondary)

Normalizes a command that has two possible names. If either of the commands has a null or empty value, those keys are removed. If both the the primary and secondary are present, the secondary is removed. Otherwise, the secondary is renamed to the primary name.

void SetDefaultImageFormat(string format)

If 'thumbnail' and 'format' are not specified, sets 'format' to the specified value.

string ToStringEncoded()

Returns a querystring with all the settings in this class. Querystring keys and values are URL encoded properly.

bool WasOneSpecified(String[] keys)

Returns true if any of the specified keys are present in this NameValueCollection

Public properties

String[] AllKeys get;

ContentAlignment Anchor get; set;

How to anchor the image when cropping or adding whitespace to meet sizing requirements.

Color BackgroundColor get; set;

["bgcolor"]: Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).

BoxPadding Border get; set;

Friendly get/set accessor for the ["borderWidth"] value. Returns BoxPadding.Empty when unspecified.

Color BorderColor get; set;

Gets/sets ["borderColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).

ServerCacheMode Cache get; set;

["cache"]: Server caching mode suggestion for the result

int Count get;

PointF CropBottomRight get; set;

["crop"]=(x1,y1,[x2],[y2]). Sets x2 and y2, the bottom-right corner of the crop rectangle. If 1 or greater, the coordinate is relative to the top-left corner of the image. If 0 or less, the value is relative to the bottom-right corner. This allows for easy trimming: crop=(10,10,-10,-10). Set ["cropxunits"] and ["cropyunits"] to the width/height of the rectangle your coordinates are relative to, if different from the original image size.

CropMode CropMode get; set;

["crop"]=none|auto Defaults to None - letterboxing is used if both width and height are supplied, and stretch = proportionally. Set CropTopLeft and CropBottomRight when you need to specify a custom crop rectangle.

PointF CropTopLeft get; set;

["crop"]=([x1],[y1],x2,y2). Sets x1 and y21, the top-right corner of the crop rectangle. If 0 or greater, the coordinate is relative to the top-left corner of the image. If less than 0, the value is relative to the bottom-right corner. This allows for easy trimming: crop=(10,10,-10,-10). Set ["cropxunits"] and ["cropyunits"] to the width/height of the rectangle your coordinates are relative to, if different from the original image size.

double CropXUnits get; set;

The width which the X and X2 crop values should be applied. For example, a value of '100' makes X and X2 percentages of the original image width. This can be set to any non-negative value. Very useful for performing cropping when the original image size is unknown. 0 indicates that the crop values are relative to the original size of the image.

double CropYUnits get; set;

The width which the Y and Y2 crop values should be applied. For example, a value of '100' makes Y and Y2 percentages of the original image height. This can be set to any non-negative value. Very useful for performing cropping when the original image size is unknown. 0 indicates that the crop values are relative to the original size of the image.

RotateFlipType Flip get; set;

Allows you to flip the entire resulting image vertically, horizontally, or both. Rotation is not supported.

string Format get; set;

Like this["format"]. Gets or sets the output file format to use. "png", "jpg", and "gif" are valid values. Returns null if unspecified. When format is not specified, the original format of the image is used (unless it is not a web safe format - jpeg is the fallback in that scenario).

int Height get; set;

["height"]: Sets the desired height of the image. (minus padding, borders, margins, effects, and rotation) The only instance the resulting image will be smaller is if the original source image is smaller. Set Scale=Both to upscale these images and ensure the output always matches 'width' and 'height'. If both width and height are specified, the image will be 'letterboxed' to match the desired aspect ratio. Change the Mode property to adjust this behavior.

string Item get; set;

KeysCollection Keys get;

BoxPadding Margin get; set;

["margin"]: Gets/sets the width(s) of the margin outside the image border and effects.

int MaxHeight get; set;

["maxheight"]: Sets the maximum desired height of the image. (minus padding, borders, margins, effects, and rotation). The image may be smaller than this value to maintain aspect ratio when both maxwidth and maxheight are specified.

int MaxWidth get; set;

["maxwidth"]: Sets the maximum desired width of the image. (minus padding, borders, margins, effects, and rotation). The image may be smaller than this value to maintain aspect ratio when both maxwidth and maxheight are specified.

FitMode Mode get; set;

["mode"]: Sets the fit mode for the image. max, min, pad, crop, carve, stretch

BoxPadding Padding get; set;

["paddingWidth"]: Gets/sets the width(s) of padding inside the image border.

Color PaddingColor get; set;

Gets/sets ["paddingColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).

ProcessWhen Process get; set;

["process"]: Server processing suggestion for the result. Allows you to 'disable' processing of the image (so you can use disk caching with non-image files). Allows you to 'force' processing of the image, for images without a querystring.

int Quality get; set;

["quality"]: The jpeg encoding quality to use. (10..100). 90 is the default and best value, you should leave it.

double Rotate get; set;

["rotate"] The degress to rotate the image clockwise. -360 to 360.

ScaleMode Scale get; set;

["scale"] Whether to downscale, upscale, upscale the canvas, or both upscale or downscale the image as needed. Defaults to DownscaleOnly. See the DefaultSettings plugin to adjust the default.

RotateFlipType SourceFlip get; set;

["sFlip"] Allows you to flip the source image vertically, horizontally, or both. Rotation is not supported.

StretchMode Stretch get; set;

[Deprecated] (Replaced by mode=stretch) Whether to preserve aspect ratio or stretch to fill the bounds.

int Width get; set;

["width"]: Sets the desired width of the image. (minus padding, borders, margins, effects, and rotation). The only instance the resulting image will be smaller is if the original source image is smaller. Set Scale=Both to upscale these images and ensure the output always matches 'width' and 'height'. If both width and height are specified, the image will be 'letterboxed' to match the desired aspect ratio. Change the Mode property to adjust this behavior.