Image resizing for dotnet core mvc projects using ImageMagick
C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
README.md

README.md

Build status

Q42.ImageResizert

Image resizing for dotnet core mvc projects using ImageMagick 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