Table of Contents

Class ImageCacheExtensions

Namespace
Akavache.Drawing
Assembly
Akavache.Drawing.dll

Advanced image caching and manipulation extensions.

public static class ImageCacheExtensions
Inheritance
ImageCacheExtensions

Methods

ClearImageCache(IBlobCache, Func<string, bool>)

Clear all cached images that match a specific pattern.

public static IObservable<Unit> ClearImageCache(this IBlobCache blobCache, Func<string, bool> keyPattern)

Parameters

blobCache IBlobCache

The blob cache to clear images from.

keyPattern Func<string, bool>

A function to determine if a key should be invalidated.

Returns

IObservable<Unit>

An observable that completes when all matching images are cleared.

CreateAndCacheThumbnail(IBlobCache, string, string, float, float, DateTimeOffset?)

Create a thumbnail version of an image and cache it separately.

public static IObservable<Unit> CreateAndCacheThumbnail(this IBlobCache blobCache, string sourceKey, string thumbnailKey, float thumbnailWidth, float thumbnailHeight, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to store the thumbnail in.

sourceKey string

The key of the source image.

thumbnailKey string

The key to store the thumbnail under.

thumbnailWidth float

The desired thumbnail width.

thumbnailHeight float

The desired thumbnail height.

absoluteExpiration DateTimeOffset?

Optional expiration date for the thumbnail.

Returns

IObservable<Unit>

An observable that completes when the thumbnail is created and cached.

GetImageSize(IBlobCache, string)

Get the size information of a cached image without fully loading it.

public static IObservable<Size> GetImageSize(this IBlobCache blobCache, string key)

Parameters

blobCache IBlobCache

The blob cache containing the image.

key string

The key of the image.

Returns

IObservable<Size>

An observable containing the image size information.

LoadImageFromUrlWithFallback(IBlobCache, string, byte[], bool, float?, float?, DateTimeOffset?)

Load an image from URL with automatic fallback to a default image if loading fails.

public static IObservable<IBitmap> LoadImageFromUrlWithFallback(this IBlobCache blobCache, string url, byte[] fallbackImageBytes, bool fetchAlways = false, float? desiredWidth = null, float? desiredHeight = null, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from.

url string

The URL to download.

fallbackImageBytes byte[]

Default image bytes to use if loading fails.

fetchAlways bool

If we should always fetch the image from the URL.

desiredWidth float?

Optional desired width.

desiredHeight float?

Optional desired height.

absoluteExpiration DateTimeOffset?

Optional expiration date.

Returns

IObservable<IBitmap>

The loaded image or the fallback image.

LoadImageWithFallback(IBlobCache, string, byte[], float?, float?)

Load an image with automatic fallback to a default image if loading fails.

public static IObservable<IBitmap> LoadImageWithFallback(this IBlobCache blobCache, string key, byte[] fallbackImageBytes, float? desiredWidth = null, float? desiredHeight = null)

Parameters

blobCache IBlobCache

The blob cache to load the image from.

key string

The key to look up in the cache.

fallbackImageBytes byte[]

Default image bytes to use if loading fails.

desiredWidth float?

Optional desired width.

desiredHeight float?

Optional desired height.

Returns

IObservable<IBitmap>

The loaded image or the fallback image.

LoadImages(IBlobCache, IEnumerable<string>, float?, float?)

Load multiple images from the cache with specified keys.

public static IObservable<KeyValuePair<string, IBitmap>> LoadImages(this IBlobCache blobCache, IEnumerable<string> keys, float? desiredWidth = null, float? desiredHeight = null)

Parameters

blobCache IBlobCache

The blob cache to load images from.

keys IEnumerable<string>

The keys to look up in the cache.

desiredWidth float?

Optional desired width for all images.

desiredHeight float?

Optional desired height for all images.

Returns

IObservable<KeyValuePair<string, IBitmap>>

An observable sequence of key-bitmap pairs.

PreloadImagesFromUrls(IBlobCache, IEnumerable<string>, DateTimeOffset?)

Preload and cache images from multiple URLs.

public static IObservable<Unit> PreloadImagesFromUrls(this IBlobCache blobCache, IEnumerable<string> urls, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to store images in.

urls IEnumerable<string>

The URLs to download and cache.

absoluteExpiration DateTimeOffset?

Optional expiration date for cached images.

Returns

IObservable<Unit>

An observable that completes when all images are cached.