Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 1.6 KB

README.md

File metadata and controls

47 lines (36 loc) · 1.6 KB

Build status

Q42.ImageResizert

Image resizing for dotnet core mvc projects using ImageSharp and Azure storage.

Include this package in any dot net core mvc file and /image/{imageId}?w=200&h=300&cover=true&quality=90 will handle imageresizing.

Q42.ImageResizertService

You can also use the ImageResizertService directly

var service = new ImageResizertService(settings);

Configure

services.Configure<ImageResizertSettings>(Configuration.GetSection("ImageResizerSettings"));
"ImageResizerSettings": {
    "AzureConnectionString": "DefaultEndpointsProtocol=https;AccountName=<yourname>;AccountKey=<yourkey>",
    "AssetContainerName": "<yourname>",    
    "CompressionQuality": "<1-100>",
    
    // optional settings
    "CacheContainerName":  "<mycachecontanier>",
    "CacheFolderName": "<mycachefolder>", // defaults to imagecache
    "BaseUrl": "<your application url>" // when configured, only absolute urls will be returned
    "ImageCdn": "<your cdn url>" // when configured, only absolute urls will be returned. Overrides BaseUrl
  }

Caching

By default, all images that are created and stored in <CacheFolderName>/{id}-{width}-{height}-{cover}-{quality}. Currently you can only clear these by deleting the imagecache folder.

Razor view helper

To use the UrlHelper shorthands

<img src="@UrlHelper.GetBaseUrlForImage(item.ImageId)" />

add this line to _ViewImports.csthml

@inject Q42.ImageResizer.UrlHelper UrlHelper