Skip to content

Latest commit

 

History

History
105 lines (77 loc) · 3.3 KB

README.md

File metadata and controls

105 lines (77 loc) · 3.3 KB

ImageResizer.AspNetCore

Development

Build status NuGet GitHub issues GitHub stars GitHub license

You can see the DEMO here: Demo

Before posting new issues: Test samples

Current version: 2.0.x [Stable]

In this version: all main functionality working except for disk cache and watermark which will be added soon the watermark as a text just added but need some bug fix

Overview

it's for DotNetCore only

aspnetcore 2.0 +

Easy to install

Use the library as dll, reference from nuget or use this in package manager console

Install-Package ImageResizer.AspNetCore

Wiki

for using this awesome library, you only need to add two things

first: add this line of code to your Startup.cs

public void ConfigureServices(IServiceCollection services)
{
  services.AddSingleton<IFileProvider>(_ => new PhysicalFileProvider(_env.WebRootPath ?? _env.ContentRootPath));
  //...
  services.AddImageResizer();
  //...
}

you may need this:

 private readonly IWebHostEnvironment _env;
 public Startup(IWebHostEnvironment env)
 {
     _env = env;
     var builder = new ConfigurationBuilder()
       .SetBasePath(env.ContentRootPath)
       .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
       .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
       .AddEnvironmentVariables();
       Configuration = builder.Build();
}

Then this one :

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
  //...
  app.UseStaticFiles();
  app.UseImageResizer();
  //...
}

and you can use it in your client-side(html,css,ts,...) just like below:

Simple As That Enjoy :))

<img src="~/images/mardinCity.jpg?w=200" />
<img src="~/images/mardinCity.jpg?h=300" />
<img src="~/images/mardinCity.jpg?format=png" />
<img src="~/images/mardinCity.jpg?format=jpg" />
<img src="~/images/mardinCity.jpg?format=jpeg" />
<img src="~/images/mardinCity.jpg?w=100&h=200&mode=pad" />
<img src="~/images/mardinCity.jpg?w=100&h=200&mode=max" />
<img src="~/images/mardinCity.jpg?w=100&h=200&mode=crop" />
<img src="~/images/mardinCity.jpg?w=100&h=200&mode=stretch" />
<img src="~/images/mardinCity.jpg?autorotate=true" />
<img src="~/images/mardinCity.jpg?autorotate=false" />
<img src="~/images/mardinCity.jpg?quality=5" />
<img src="~/images/mardinCity.jpg?w=400&quality=80" />