Interface IImageCache
Used to register a service for caching images.
Namespace: AdaptiveImages.Cache
Assembly: AdaptiveImages.dll
Syntax
public interface IImageCache
Methods
Delete(string, string)
Removes an image, and all its derivatives, from the cache.
Declaration
Task Delete(string providerName, string imageId)
Parameters
Type | Name | Description |
---|---|---|
string | providerName | Name of the image provider. |
string | imageId | Unique identifier within the associated image provider. |
Returns
Type | Description |
---|---|
Task |
Load(string, string, int?, int?, int?, int?, int?, int?, bool, int?)
Loads a a cached image, if one exists, for the specified parameters.
Declaration
Task<(Stream? image, string? mimeType)> Load(string providerName, string imageId, int? width = null, int? height = null, int? cropleft = null, int? croptop = null, int? cropright = null, int? cropbottom = null, bool thumbnail = false, int? quality = null)
Parameters
Type | Name | Description |
---|---|---|
string | providerName | Name of the image provider. |
string | imageId | Unique identifier within the associated image provider. |
int? | width | Final rendering width. |
int? | height | Final rendering height. |
int? | cropleft | Number of pixels to crop from the left of the original image. |
int? | croptop | Number of pixels to crop from the top of the original image. |
int? | cropright | Number of pixels to crop from the right of the original image. |
int? | cropbottom | Number of pixels to crop from the bottom of the original image. |
bool | thumbnail | Whether the final image is for a thumbnail, which may affect rendering options. |
int? | quality | A number between 0 and 100 to explicitly specify quality, i.e. compression, of the final image. |
Returns
Type | Description |
---|---|
Task<(Stream image, string mimeType)> | Stream for the image binary data, and its MIME type. |
Save(Stream, string, string, int?, int?, int?, int?, int?, int?, bool, int?)
Writes an image, with a specific set of parameters, to the cache.
Declaration
Task Save(Stream image, string providerName, string imageId, int? width = null, int? height = null, int? cropleft = null, int? croptop = null, int? cropright = null, int? cropbottom = null, bool thumbnail = false, int? quality = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | image | Raw binary data of the image. |
string | providerName | Name of the image provider. |
string | imageId | Unique identifier within the associated image provider. |
int? | width | Final rendering width. |
int? | height | Final rendering height. |
int? | cropleft | Number of pixels that were cropped from the left of the original image. |
int? | croptop | Number of pixels that were cropped from the top of the original image. |
int? | cropright | Number of pixels that were cropped from the right of the original image. |
int? | cropbottom | Number of pixels that were cropped from the bottom of the original image. |
bool | thumbnail | Whether the final image is for a thumbnail. |
int? | quality | Explicitly specified quality, i.e. compression, of the final image. |
Returns
Type | Description |
---|---|
Task |