ImageResizer
3.4.0
|
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 More...
Public Member Functions | |
ResizeSettings () | |
Creates an empty settings collection. More... | |
ResizeSettings (NameValueCollection col) | |
Copies the specified collection into a new ResizeSettings instance. More... | |
ResizeSettings (string queryString) | |
Parses the specified querystring into name/value pairs. leading ? not required. Discards everything after the first '#' character as a URL fragment. More... | |
ResizeSettings (int width, int height, FitMode mode, string imageFormat) | |
Creates a new resize settings object with the specified resizing settings More... | |
bool | WasOneSpecified (params string[] keys) |
Returns true if any of the specified keys are present in this NameValueCollection More... | |
RectangleF | getCustomCropSourceRect (SizeF imageSize) |
void | SetDefaultImageFormat (string format) |
If 'thumbnail' and 'format' are not specified, sets 'format' to the specified value. More... | |
override string | ToString () |
Returns a string containing all the settings in the class, in querystring form. Use ToStringEncoded() to get a URL-safe querystring. This method does not encode commas, spaces, etc. More... | |
string | ToStringEncoded () |
Returns a querystring with all the settings in this class. Querystring keys and values are URL encoded properly. More... | |
void | Normalize () |
This method will 'normalize' command aliases to the primary key name and resolve duplicates. w->width, h->height, sourceFlip->sFlip, thumbnail->format More... | |
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. More... | |
Protected Member Functions | |
int | get (string name, int defaultValue) |
void | set (string name, int value) |
double | get (string name, double defaultValue) |
void | set (string name, double value) |
Properties | |
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. More... | |
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. More... | |
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. More... | |
int | Quality [get, set] |
["quality"]: The jpeg encoding quality to use. (10..100). 90 is the default and best value, you should leave it. More... | |
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. More... | |
FitMode | Mode [get, set] |
["mode"]: Sets the fit mode for the image. max, min, pad, crop, carve, stretch More... | |
double | Rotate [get, set] |
["rotate"] The degress to rotate the image clockwise. -360 to 360. More... | |
ContentAlignment | Anchor [get, set] |
How to anchor the image when cropping or adding whitespace to meet sizing requirements. More... | |
RotateFlipType | Flip [get, set] |
Allows you to flip the entire resulting image vertically, horizontally, or both. Rotation is not supported. More... | |
RotateFlipType | SourceFlip [get, set] |
["sFlip"] Allows you to flip the source image vertically, horizontally, or both. Rotation is not supported. More... | |
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. More... | |
StretchMode | Stretch [get, set] |
[Deprecated] (Replaced by mode=stretch) Whether to preserve aspect ratio or stretch to fill the bounds. More... | |
ServerCacheMode | Cache [get, set] |
["cache"]: Server caching mode suggestion for the result More... | |
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. More... | |
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. More... | |
double[] | CropValues [get, set] |
4 values specify x1,y1,x2,y2 values for the crop rectangle. Negative values are relative to the bottom right - on a 100x100 picture, (10,10,90,90) is equivalent to (10,10,-10,-10). And (0,0,0,0) is equivalent to (0,0,100,100). More... | |
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. More... | |
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. More... | |
Color | BackgroundColor [get, set] |
["bgcolor"]: Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits). More... | |
Color | PaddingColor [get, set] |
Gets/sets ["paddingColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits). More... | |
BoxPadding | Padding [get, set] |
["paddingWidth"]: Gets/sets the width(s) of padding inside the image border. More... | |
BoxPadding | Margin [get, set] |
["margin"]: Gets/sets the width(s) of the margin outside the image border and effects. More... | |
Color | BorderColor [get, set] |
Gets/sets ["borderColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits). More... | |
BoxPadding | Border [get, set] |
Friendly get/set accessor for the ["borderWidth"] value. Returns BoxPadding.Empty when unspecified. More... | |
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). More... | |
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. More... | |
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. More... | |
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
Definition at line 20 of file ResizeSettings.cs.
|
inline |
Creates an empty settings collection.
Definition at line 25 of file ResizeSettings.cs.
|
inline |
Copies the specified collection into a new ResizeSettings instance.
col |
Definition at line 30 of file ResizeSettings.cs.
|
inline |
Parses the specified querystring into name/value pairs. leading ? not required. Discards everything after the first '#' character as a URL fragment.
queryString |
Definition at line 36 of file ResizeSettings.cs.
|
inline |
Creates a new resize settings object with the specified resizing settings
width | |
height | |
mode | |
imageFormat | The desired image format, like 'jpg', 'gif', or 'png'. Leave null if you want to preserve the original format. |
Definition at line 45 of file ResizeSettings.cs.
|
inline |
This method will 'normalize' command aliases to the primary key name and resolve duplicates. w->width, h->height, sourceFlip->sFlip, thumbnail->format
Definition at line 398 of file ResizeSettings.cs.
|
inline |
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.
primary | |
secondary |
Definition at line 415 of file ResizeSettings.cs.
|
inline |
If 'thumbnail' and 'format' are not specified, sets 'format' to the specified value.
format |
Definition at line 374 of file ResizeSettings.cs.
|
inline |
Returns a string containing all the settings in the class, in querystring form. Use ToStringEncoded() to get a URL-safe querystring. This method does not encode commas, spaces, etc.
Definition at line 383 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.Watermark.ImageLayer.GetMemCachedBitmap().
|
inline |
Returns a querystring with all the settings in this class. Querystring keys and values are URL encoded properly.
Definition at line 390 of file ResizeSettings.cs.
|
inline |
Returns true if any of the specified keys are present in this NameValueCollection
keys |
Definition at line 132 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.SimpleFilters.SimpleFilters.PostCreateImageAttributes(), and ImageResizer.Plugins.AdvancedFilters.AdvancedFilters.PreRenderImage().
|
getset |
How to anchor the image when cropping or adding whitespace to meet sizing requirements.
Definition at line 146 of file ResizeSettings.cs.
|
getset |
["bgcolor"]: Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).
Definition at line 278 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.FreeImageBuilder.FreeImageBuilderPlugin.buildFiBitmap(), and ImageResizer.ImageBuilder.RenderPadding().
|
getset |
Friendly get/set accessor for the ["borderWidth"] value. Returns BoxPadding.Empty when unspecified.
Definition at line 322 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutBorder(), and ImageResizer.ImageBuilder.RenderBorder().
|
getset |
Gets/sets ["borderColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).
Definition at line 315 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.RenderBorder().
|
getset |
["cache"]: Server caching mode suggestion for the result
Definition at line 196 of file ResizeSettings.cs.
|
getset |
["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.
Definition at line 266 of file ResizeSettings.cs.
|
getset |
["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.
Definition at line 222 of file ResizeSettings.cs.
|
getset |
["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.
Definition at line 252 of file ResizeSettings.cs.
|
getsetprotected |
4 values specify x1,y1,x2,y2 values for the crop rectangle. Negative values are relative to the bottom right - on a 100x100 picture, (10,10,90,90) is equivalent to (10,10,-10,-10). And (0,0,0,0) is equivalent to (0,0,100,100).
Definition at line 236 of file ResizeSettings.cs.
|
getset |
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.
Definition at line 354 of file ResizeSettings.cs.
|
getset |
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.
Definition at line 360 of file ResizeSettings.cs.
|
getset |
Allows you to flip the entire resulting image vertically, horizontally, or both. Rotation is not supported.
Definition at line 155 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.ProcessFinalBitmap().
|
getset |
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).
Also checks the 'thumbnail' value for V2 compatibility. When set, 'thumnail' is removed and only 'format' is used.
Definition at line 338 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.WebPEncoder.WebPEncoderPlugin.CreateIfSuitable(), and ImageResizer.Plugins.Basic.DefaultEncoder.CreateIfSuitable().
|
getset |
["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.
Definition at line 79 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.PdfRenderer.PdfRendererPlugin.DecodeStream(), ImageResizer.Plugins.CropAround.CropAroundPlugin.LayoutImage(), and ImageResizer.ImageBuilder.LayoutImage().
|
getset |
["margin"]: Gets/sets the width(s) of the margin outside the image border and effects.
Definition at line 304 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutMargin().
|
getset |
["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.
Definition at line 111 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutImage().
|
getset |
["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.
Definition at line 89 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutImage().
|
getset |
["mode"]: Sets the fit mode for the image. max, min, pad, crop, carve, stretch
Definition at line 118 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.CropAround.CropAroundPlugin.LayoutImage(), and ImageResizer.Plugins.Basic.DefaultSettings.Modify().
|
getset |
["paddingWidth"]: Gets/sets the width(s) of padding inside the image border.
Definition at line 293 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutPadding().
|
getset |
Gets/sets ["paddingColor"]. Named and hex values are supported. (rgb and rgba, both 3, 6, and 8 digits).
Definition at line 286 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.RenderPadding().
|
getset |
["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.
Definition at line 208 of file ResizeSettings.cs.
|
getset |
["quality"]: The jpeg encoding quality to use. (10..100). 90 is the default and best value, you should leave it.
Definition at line 97 of file ResizeSettings.cs.
|
getset |
["rotate"] The degress to rotate the image clockwise. -360 to 360.
Definition at line 138 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutRotate().
|
getset |
["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.
Definition at line 176 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.LayoutImage().
|
getset |
["sFlip"] Allows you to flip the source image vertically, horizontally, or both. Rotation is not supported.
Definition at line 164 of file ResizeSettings.cs.
Referenced by ImageResizer.ImageBuilder.PrepareSourceBitmap().
|
getset |
[Deprecated] (Replaced by mode=stretch) Whether to preserve aspect ratio or stretch to fill the bounds.
Definition at line 186 of file ResizeSettings.cs.
|
getset |
["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.
Definition at line 66 of file ResizeSettings.cs.
Referenced by ImageResizer.Plugins.PdfRenderer.PdfRendererPlugin.DecodeStream(), ImageResizer.Plugins.CropAround.CropAroundPlugin.LayoutImage(), and ImageResizer.ImageBuilder.LayoutImage().