Skip to content
Image thumbnail service based on ASP.NET Core
Branch: master
Clone or download
Latest commit 2f504e5 Jul 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src added dpr filter Jul 16, 2019
LICENSE Initial commit Jun 3, 2019
README.md Update README.md Jul 16, 2019

README.md

ImageWizard

A webservice to manipulate your images dynamically.

Package Release
ImageWizard.Core NuGet
ImageWizard.MongoDB NuGet
ImageWizard.AspNetCore NuGet

Overview

Example:

https://localhost/image/WZy86ixQq9EogpyHwMYd7F5wKa0/trim()/resize(200,200)/jpg(90)/fetch/https://upload.wikimedia.org/wikipedia/commons/b/b7/Europe_topography_map.png

Description Url segment
base path "image"
signature based on HMACSHA1 "WZy86ixQq9EogpyHwMYd7F5wKa0" or "unsafe" (if enabled)
any filters "trim()/resize(200,200)/jpg(90)"
delivery type "fetch"
absolute url of the original image https://upload.wikimedia.org/wikipedia/commons/b/b7/Europe_topography_map.png

Image filters

Image transformations

  • resize(size)
  • resize(width,height)
  • resize(width,height,mode)
    • mode: min, max, crop, pad, stretch
  • crop(width,height)
  • crop(x,y,width,height) //int for absolute values, 0.0 to 1.0 for relative values
  • flip(type)
    • type: horizontal, vertical
  • rotate(value)
    • value: 90, 180 or 270
  • trim()
  • grayscale()
  • blackwhite()
  • blur()
  • invert()
  • brightness(value)
  • contrast(value)

Output formats

  • jpg()
  • jpg(quality)
  • png()
  • gif()
  • bmp()

Image loaders

  • HTTP loader ("fetch")
    • absolute url of the original image
  • file loader ("upload")
    • relative url to file
  • youtube loader ("youtube")
    • video id

Image caches

  • file cache
  • distributed cache
    • MS SQL
    • Redis
  • MongoDB cache

Integrate into existing ASP.NET Core applications

https://www.nuget.org/packages/ImageWizard.Core/

services.AddImageWizard(options => 
                       {
                           options.AllowUnsafeUrl = true;                           
                           options.Key = "DEMO-KEY...";
                           options.UseETag = true;
                       })
                       //use file cache
                       .SetFileCache(options => options.Folder = "FileCache")
                       //or MongoDB cache
                       .SetMongoDBCache(options => options.Hostname = "localhost")
                       //or distributed cache
                       .SetDistributedCache()
                       //add some loaders
                       .AddHttpLoader()
                       .AddYoutubeLoader()
                       .AddFileLoader(options => options.Folder = "FileStorage");
app.UseImageWizard();

ASP.NET Core UrlBuilder

https://www.nuget.org/packages/ImageWizard.AspNetCore/

Example:

Add settings to the appsettings.json

 "ImageWizard": {
    "BaseUrl": "https://<your-domain>/image",
    "Key": "DEMO-KEY---PLEASE-CHANGE-THIS-KEY---PLEASE-CHANGE-THIS-KEY---PLEASE-CHANGE-THIS-KEY---==",
    "Enabled": true
  }

Register settings to services

services.Configure<ImageWizardSettings>(Configuration.GetSection("ImageWizard"));

services.AddImageWizard();

//or

services.AddImageWizard(options => 
{
    options.BaseUrl = "https://<your-domain>/image";
    options.Key = "..";
    options.Enabled = true;
});

Create url with fluent api

@Url
.ImageWizard()
//use HTTP loader
.Fetch("https://<your-domain>/test/picture.jpg")
//or file loader
.Upload("test/picture.jpg")
.Trim()
.Resize(160,140)
.Jpg(90)
.BuildUrl()
You can’t perform that action at this time.