Table of Contents

Class FormatUtilities

Namespace
SixLabors.ImageSharp.Web
Assembly
SixLabors.ImageSharp.Web.dll

Contains various helper methods for working with image formats based on the given configuration.

public sealed class FormatUtilities
Inheritance
FormatUtilities
Inherited Members

Constructors

FormatUtilities(IOptions<ImageSharpMiddlewareOptions>)

Initializes a new instance of the FormatUtilities class.

public FormatUtilities(IOptions<ImageSharpMiddlewareOptions> options)

Parameters

options IOptions<ImageSharpMiddlewareOptions>

The middleware options.

Methods

GetExtensionFromContentType(string)

Gets the correct extension for the given content type (mime-type).

public string GetExtensionFromContentType(string contentType)

Parameters

contentType string

The content type (mime-type).

Returns

string

The string.

TryGetExtensionFromUri(string, out string?)

Gets the file extension for the given image uri.

public bool TryGetExtensionFromUri(string uri, out string? extension)

Parameters

uri string

The full request uri.

extension string

When this method returns, contains the file extension for the image source, if the path exists; otherwise, the default value for the type of the path parameter. This parameter is passed uninitialized.

Returns

bool

true if the uri contains an extension; otherwise, false.