Class ProcessImageSettings
Defines settings for a MagicImageProcessor pipeline operation.
Inheritance
Namespace: PhotoSauce.MagicScaler
Assembly: PhotoSauce.MagicScaler.dll
Syntax
public sealed class ProcessImageSettings : Object
Constructors
ProcessImageSettings()
Declaration
public ProcessImageSettings()
Properties
Anchor
Determines which part of the image is preserved when automatic cropping is performed.
Declaration
public CropAnchor Anchor { get; set; }
Property Value
Type | Description |
---|---|
CropAnchor | Default value: Center |
Remarks
By default, auto-cropping will maintain the image center by cropping equally from the top, bottom, or sides.
If you wish to direct the auto-cropper to focus on another part of the image, you may specify a vertical and horizontal bias using a combination of values. Only one horizontal and one vertical value may be combined.
Examples
mySettings.Anchor = CropAnchor.Top | CropAnchor.Left
BlendingMode
Determines whether pixel blending is done using linear RGB or gamma-companded R'G'B'.
Declaration
public GammaMode BlendingMode { get; set; }
Property Value
Type | Description |
---|---|
GammaMode | Default value: Linear |
Remarks
Linear processing will yield better quality in almost all cases but with a performance cost.
ColorProfileMode
Determines whether automatic colorspace conversion is performed.
Declaration
public ColorProfileMode ColorProfileMode { get; set; }
Property Value
Type | Description |
---|---|
ColorProfileMode | Default value: Normalize |
Crop
Defines the bounding rectangle to use from the input image. Can be calculated automatically depending on CropScaleMode.
Declaration
public Rectangle Crop { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Rectangle | Default value: System.Drawing.Rectangle.Empty |
Remarks
If the input image has an Exif Orientation value, rotation and/or flipping will be applied to the image before the crop. Crop values should be expressed in terms of the image's correct orientation, not the encoded orientation.
CropBasis
Defines the dimensions on which the Crop rectangle is based. If this value is empty, Crop values are based on the actual input image dimensions.
Declaration
public Size CropBasis { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Size | Default value: System.Drawing.Size.Empty |
DecoderOptions
Codec options to be passed to the image decoder.
Declaration
public IDecoderOptions DecoderOptions { get; set; }
Property Value
Type | Description |
---|---|
IDecoderOptions | Default value: taken from the codec's default configuration. |
Default
An empty settings object, useful for transcode-only operations.
Declaration
public static ProcessImageSettings Default { get; }
Property Value
Type | Description |
---|---|
ProcessImageSettings |
DpiX
The horizontal DPI of the output image. A value of 0
will preserve the DPI of the input image.
Declaration
public double DpiX { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Default value: |
Remarks
This affects the image metadata only. Not all image formats support a DPI setting and most applications will ignore it.
DpiY
The vertical DPI of the output image. A value of 0
will preserve the DPI of the input image.
Declaration
public double DpiY { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Default value: |
Remarks
This affects the image metadata only. Not all image formats support a DPI setting and most applications will ignore it.
EncoderOptions
Codec options to be passed to the image encoder.
Declaration
public IEncoderOptions EncoderOptions { get; set; }
Property Value
Type | Description |
---|---|
IEncoderOptions | Default value: calculated based on input image properties and ouput size, or taken from the codec's configuration. |
Height
The height of the output image in pixels. If auto-cropping is enabled, a value of 0
will set the height automatically based on the output width.
Declaration
public int Height { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Default value: |
Remarks
If Width and Height are both set to 0
, no resizing will be performed but a crop may still be applied.
HybridMode
Determines whether Hybrid Scaling is allowed to be used to improve performance.
Declaration
public HybridScaleMode HybridMode { get; set; }
Property Value
Type | Description |
---|---|
HybridScaleMode | Default value: FavorQuality |
Remarks
Hybrid processing may use the image decoder or another lower-quality scaler to shrink an image to an intermediate size before the selected high-quality algorithm is applied to the final resize. This can result in dramatic performance improvements but with a slight reduction in image quality.
HybridScaleRatio
The calculated ratio for the lower-quality portion of a hybrid scaling operation.
Declaration
public int HybridScaleRatio { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Calculated based on HybridScaleMode and the ratio of input image size to output image size |
Interpolation
Determines how resampling interpolation is performed.
Declaration
public InterpolationSettings Interpolation { get; set; }
Property Value
Type | Description |
---|---|
InterpolationSettings | Default value: calculated based on resize ratio |
Remarks
If this value is unset, the algorithm will be chosen automatically to maximize image quality and performance based on the ratio of input image size to output image size.
MatteColor
The background color to use when converting to a non-transparent format and the fill color for Pad mode.
Declaration
public Color MatteColor { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Color | Default value: System.Drawing.Color.Empty |
Remarks
When converting to a file format that does not support transparency (e.g. PNG->JPEG), the background color will be System.Drawing.Color.Black unless otherwise specified. When saving as a file format that does support transparency, the transparency will be maintained unless a color is set.
MetadataNames
A list of metadata policy names or explicit metadata paths to be copied from the input image to the output image.
Declaration
public IEnumerable<string> MetadataNames { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | Default value: System.Linq.Enumerable.Empty``1 |
Remarks
This feature can be useful for preserving author, copyright, or other important EXIF tags in the output image. Values will be copied only if present in the input image and supported by the output codec. See the Windows Photo Metadata Policies for examples of commonly-used values, or the Metadata Query Language Overview for explicit path syntax.
OrientationMode
Determines whether automatic orientation correction is performed.
Declaration
public OrientationMode OrientationMode { get; set; }
Property Value
Type | Description |
---|---|
OrientationMode | Default value: Normalize |
ResizeMode
Determines how automatic scaling and cropping is performed.
Declaration
public CropScaleMode ResizeMode { get; set; }
Property Value
Type | Description |
---|---|
CropScaleMode | Default value: Crop |
Remarks
Auto-cropping is performed only if a Crop value is not explicitly set.
Sharpen
Determines whether automatic sharpening is applied during processing. The sharpening settings are controlled by the UnsharpMask property.
Declaration
public bool Sharpen { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Default value: true |
UnsharpMask
Settings for automatic post-resize sharpening.
Declaration
public UnsharpMaskSettings UnsharpMask { get; set; }
Property Value
Type | Description |
---|---|
UnsharpMaskSettings | Default value: calculated based on resize ratio |
Remarks
If this value is unset, the settings will be chosen automatically to maximize image quality based on the ratio of input image size to output image size.
Width
The width of the output image in pixels. If auto-cropping is enabled, a value of 0
will set the width automatically based on the output height.
Declaration
public int Width { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Default value: |
Remarks
If Width and Height are both set to 0
, no resizing will be performed but a crop may still be applied.
Methods
Calculate(ProcessImageSettings, ImageFileInfo)
Create a new ProcessImageSettings instance with settings calculated for a specific input image.
Declaration
public static ProcessImageSettings Calculate(ProcessImageSettings settings, ImageFileInfo imageInfo)
Parameters
Type | Name | Description |
---|---|---|
ProcessImageSettings | settings | The input settings. |
ImageFileInfo | imageInfo | The input image for which the new settings should be calculated. |
Returns
Type | Description |
---|---|
ProcessImageSettings | The calculated settings for the input image. |
TrySetEncoderFormat(String)
Sets the preferred format of the output image. If no encoder is set, the pipeline will choose the output codec based on the input image type or EncoderOptions.
Declaration
public bool TrySetEncoderFormat(string mimeType)
Parameters
Type | Name | Description |
---|---|---|
System.String | mimeType | The MIME type of the preferred encoder. Common formats can be found in ImageMimeTypes. |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
If a matching encoder is not registered, the pipeline may choose an alternate encoder.