Class ImageRenderSettings
Represents transformation settings for an image to render.
Inherited Members
Namespace: AdaptiveImages.Rendering
Assembly: AdaptiveImages.dll
Syntax
public class ImageRenderSettings
Constructors
ImageRenderSettings(SingleImage)
Creates a new object for explicitly specifying rendering settings instead of retrieving them from the parent object.
Declaration
public ImageRenderSettings(SingleImage singleImage)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | singleImage | The image to render. |
Remarks
You may want to consider using the GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>) extension method on the parent instance instead of creating an ImageRenderSettings object manually, as that will not be able to automatically resolve image constraints.
ImageRenderSettings(SingleImage, CropSettings)
Creates a new object for explicitly specifying rendering settings instead of retrieving them from the parent object.
Declaration
public ImageRenderSettings(SingleImage singleImage, CropSettings cropping)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | singleImage | The image to render. |
CropSettings | cropping | Crop settings to apply instead of any crop settings applied to the image property. |
Remarks
You may want to consider using the GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>) extension method on the parent instance instead of creating an ImageRenderSettings object manually, as that will not be able to automatically resolve image constraints.
ImageRenderSettings(SingleImage, IDimensions)
Creates a new object for explicitly specifying rendering settings instead of retrieving them from the parent object.
Declaration
public ImageRenderSettings(SingleImage singleImage, IDimensions cropToSize)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | singleImage | The image to render. |
IDimensions | cropToSize | Specific dimensions to crop to. |
Remarks
You may want to consider using the GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>) extension method on the parent instance instead of creating an ImageRenderSettings object manually, as that will not be able to automatically resolve image constraints.
ImageRenderSettings(SingleImage, IProportions)
Creates a new object for explicitly specifying rendering settings instead of retrieving them from the parent object.
Declaration
public ImageRenderSettings(SingleImage singleImage, IProportions proportions)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | singleImage | The image to render. |
IProportions | proportions | Proportions constraints to apply instead of any proportions constraints. |
Remarks
You may want to consider using the GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>) extension method on the parent instance instead of creating an ImageRenderSettings object manually, as that will not be able to automatically resolve image constraints.
ImageRenderSettings(SingleImage, IProportions?, CropSettings?)
Creates a new object for explicitly specifying rendering settings instead of retrieving them from the parent object.
Declaration
public ImageRenderSettings(SingleImage singleImage, IProportions? proportions, CropSettings? cropping)
Parameters
Type | Name | Description |
---|---|---|
SingleImage | singleImage | The image to render. |
IProportions | proportions | Proportions constraints to apply instead of any proportions constraints. |
CropSettings | cropping | Crop settings to apply instead of any crop settings applied to the image property. |
Remarks
You may want to consider using the GetImageRenderSettings<TParent, TProperty>(TParent, Expression<Func<TParent, TProperty>>) extension method on the parent instance instead of creating an ImageRenderSettings object manually, as that will not be able to automatically resolve image constraints.
Properties
AlternateText
Gets or sets the alt text.
Declaration
public string? AlternateText { get; set; }
Property Value
Type | Description |
---|---|
string |
Cropped
Gets value indicating whether crop settings have been changed from the default.
Declaration
public bool Cropped { get; protected set; }
Property Value
Type | Description |
---|---|
bool |
Cropping
Gets or sets settings for how the original image should be cropped.
Declaration
public CropSettings Cropping { get; }
Property Value
Type | Description |
---|---|
CropSettings |
Remarks
The crop settings will always be relative to the original image dimensions, even if image is resized.
CssClass
Gets or sets CSS class(es) to apply.
Declaration
public string? CssClass { get; set; }
Property Value
Type | Description |
---|---|
string |
Dimensions
Gets the dimensions of the image to render.
Declaration
public Dimensions Dimensions { get; }
Property Value
Type | Description |
---|---|
Dimensions |
Image
Gets or sets the image to render.
Declaration
public SingleImage Image { get; }
Property Value
Type | Description |
---|---|
SingleImage |
LazyLoad
Gets or sets whether the image should be lazy-loaded by the browser.
Declaration
public bool LazyLoad { get; set; }
Property Value
Type | Description |
---|---|
bool |
Orientation
Gets the orientation of the resulting image.
Declaration
public Orientation Orientation { get; }
Property Value
Type | Description |
---|---|
Orientation |
ProgressiveRendering
Gets or sets whether progressive image loading should be enabled when supported.
Declaration
public ProgressiveRenderingOption ProgressiveRendering { get; set; }
Property Value
Type | Description |
---|---|
ProgressiveRenderingOption |
Proportions
Gets the proportions of the resulting image.
Declaration
public Proportions Proportions { get; }
Property Value
Type | Description |
---|---|
Proportions |
Remarks
Note that to apply proportions you need to invoke crop methods.
Quality
Gets or sets an explicit quality value between 0 and 100, or null for automatic.
Declaration
public int? Quality { get; set; }
Property Value
Type | Description |
---|---|
int? |
Resized
Gets value indicating whether image size have been changed from the default.
Declaration
public bool Resized { get; protected set; }
Property Value
Type | Description |
---|---|
bool |
Thumbnail
Gets or sets whether rendered image is intended as a thumbnail, which may apply specific render settings.
Declaration
public bool Thumbnail { get; set; }
Property Value
Type | Description |
---|---|
bool |
Title
Gets or sets an image title.
Declaration
public string? Title { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
Crop(CropSettings)
Sets new crop settings relative.
Declaration
public ImageRenderSettings Crop(CropSettings cropSettings)
Parameters
Type | Name | Description |
---|---|---|
CropSettings | cropSettings | How to crop the image using specific coordinates. |
Returns
Type | Description |
---|---|
ImageRenderSettings | Render settings with the specified cropping applied. |
Remarks
The Cropping property will always have coordinates relative to the original image, even if resizing has been applied.
Crop(IProportions)
Crops the image to specific proportions.
Declaration
public ImageRenderSettings Crop(IProportions proportions)
Parameters
Type | Name | Description |
---|---|---|
IProportions | proportions | The proportions to crop to. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
Remarks
This method overrides any explicit cropping done by a web editor.
CropToHeight(int)
Crops the image to the specified height.
Declaration
public ImageRenderSettings CropToHeight(int height)
Parameters
Type | Name | Description |
---|---|---|
int | height | Number of vertical pixels to keep. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
CropToMax(int)
Crops the image to specified max size, meaning resulting image will be square if both image width and height exceed the specified size.
Declaration
public ImageRenderSettings CropToMax(int size)
Parameters
Type | Name | Description |
---|---|---|
int | size | Maximum width and height in pixels. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
CropToWidth(int)
Crops the image to the specified width.
Declaration
public ImageRenderSettings CropToWidth(int width)
Parameters
Type | Name | Description |
---|---|---|
int | width | Number of horizontal pixels to keep. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
GetUrl(IAdaptiveImageUrlBuilder?)
Returns the URL based on the current render settings.
Declaration
public string GetUrl(IAdaptiveImageUrlBuilder? urlBuilder = null)
Parameters
Type | Name | Description |
---|---|---|
IAdaptiveImageUrlBuilder | urlBuilder |
Returns
Type | Description |
---|---|
string |
ResetCropping()
Resets any previous cropping, reverting the image to its default proportions.
Declaration
public ImageRenderSettings ResetCropping()
Returns
Type | Description |
---|---|
ImageRenderSettings |
ResizeToHeight(int)
Sets the height and also adjusts the width to maintain current image proportions.
Declaration
public ImageRenderSettings ResizeToHeight(int height)
Parameters
Type | Name | Description |
---|---|---|
int | height | Height in pixels. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
ResizeToMax(int)
Resizes the image by its longest side.
Declaration
public ImageRenderSettings ResizeToMax(int size)
Parameters
Type | Name | Description |
---|---|---|
int | size | Maximum width or height in pixels. |
Returns
Type | Description |
---|---|
ImageRenderSettings |
ResizeToWidth(int)
Sets the width and also adjusts the height to maintain image proportions.
Declaration
public ImageRenderSettings ResizeToWidth(int width)
Parameters
Type | Name | Description |
---|---|---|
int | width | Width in pixels. |
Returns
Type | Description |
---|---|
ImageRenderSettings |