Table of Contents

Class Configuration

Namespace
SixLabors.ImageSharp
Assembly
SixLabors.ImageSharp.dll

Provides configuration which allows altering default behaviour or extending the library.

public sealed class Configuration
Inheritance
Configuration
Inherited Members
Extension Methods

Constructors

Configuration()

Initializes a new instance of the Configuration class.

public Configuration()

Configuration(params IImageFormatConfigurationModule[])

Initializes a new instance of the Configuration class.

public Configuration(params IImageFormatConfigurationModule[] configurationModules)

Parameters

configurationModules IImageFormatConfigurationModule[]

A collection of configuration modules to register.

Properties

Default

Gets the default Configuration instance.

public static Configuration Default { get; }

Property Value

Configuration

ImageFormats

Gets the currently registered IImageFormats.

public IEnumerable<IImageFormat> ImageFormats { get; }

Property Value

IEnumerable<IImageFormat>

ImageFormatsManager

Gets or the ImageFormatManager that is currently in use.

public ImageFormatManager ImageFormatsManager { get; }

Property Value

ImageFormatManager

MaxDegreeOfParallelism

Gets or sets the maximum number of concurrent tasks enabled in ImageSharp algorithms configured with this Configuration instance. Initialized with ProcessorCount by default.

public int MaxDegreeOfParallelism { get; set; }

Property Value

int

MemoryAllocator

Gets or sets the MemoryAllocator that is currently in use. Defaults to Default.

Allocators are expensive, so it is strongly recommended to use only one busy instance per process. In case you need to customize it, you can ensure this by changing
public MemoryAllocator MemoryAllocator { get; set; }

Property Value

MemoryAllocator

Remarks

It's possible to reduce allocator footprint by assigning a custom instance created with Create(MemoryAllocatorOptions), but note that since the default pooling allocators are expensive, it is strictly recommended to use a single process-wide allocator. You can ensure this by altering the allocator of Default, or by implementing custom application logic that manages allocator lifetime.

If an allocator has to be dropped for some reason, ReleaseRetainedResources() shall be invoked after disposing all associated Image instances.

PreferContiguousImageBuffers

Gets or sets a value indicating whether to force image buffers to be contiguous whenever possible.

public bool PreferContiguousImageBuffers { get; set; }

Property Value

bool

Remarks

Contiguous allocations are not possible, if the image needs a buffer larger than MaxValue.

Properties

Gets a set of properties for the Configuration.

public IDictionary<object, object> Properties { get; }

Property Value

IDictionary<object, object>

Remarks

This can be used for storing global settings and defaults to be accessible to processors.

ReadOrigin

Gets or sets the position in a stream to use for reading when using a seekable stream as an image data source.

public ReadOrigin ReadOrigin { get; set; }

Property Value

ReadOrigin

StreamProcessingBufferSize

Gets or sets the size of the buffer to use when working with streams. Initialized with SixLabors.ImageSharp.Configuration.DefaultStreamProcessingBufferSize by default.

public int StreamProcessingBufferSize { get; set; }

Property Value

int

Methods

Clone()

Creates a shallow copy of the Configuration.

public Configuration Clone()

Returns

Configuration

A new configuration instance.

Configure(IImageFormatConfigurationModule)

Registers a new format provider.

public void Configure(IImageFormatConfigurationModule configuration)

Parameters

configuration IImageFormatConfigurationModule

The configuration provider to call configure on.