Image Providers
ImageSharp.Web determines the location of a source image to process via the registration and application of image providers.
Note
It is possible to configure your own image provider by implementing and registering your own version of the IImageProvider interface.
The following providers are available for the middleware. Multiples providers can be registered and will be queried for a URL match in the order of registration.
PhysicalFileSystemProvider
The PhysicalFileSystemProvider will allow the processing and serving of image files from the web root folder. This is the default provider installed when configuring the middleware.
Url matching for this provider follows the same rules as conventional static files.
AzureBlobStorageImageProvider
This provider allows the processing and serving of image files from Azure Blob Storage and is available as an external package installable via NuGet
PM > Install-Package SixLabors.ImageSharp.Web.Providers.Azure -Version VERSION_NUMBER
Once installed the provider AzureBlobContainerClientOptions can be configured as follows:
// Configure and register the container.
// Alteratively use `appsettings.json` to represent the class and bind those settings.
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
// The "BlobContainers" collection allows registration of multiple containers.
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = {AZURE_CONNECTION_STRING},
ContainerName = {AZURE_CONTAINER_NAME}
});
})
.AddProvider<AzureBlobStorageImageProvider>()
Url requests are matched in accordance to the following rule:
/{CONTAINER_NAME}/{BLOB_FILENAME}