Skip to content

Image resizing for dotnet core mvc projects using ImageMagick

Notifications You must be signed in to change notification settings

Q42/Q42.ImageResizert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Image resizing for dotnet core mvc projects using ImageMagick

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages