Git Product home page Git Product logo

imagesharp.web's Introduction

SixLabors.ImageSharp.Web
SixLabors.ImageSharp.Web

GitHub license GitHub issues GitHub stars GitHub forks Gitter

Twitter OpenCollective OpenCollective

ImageSharp.Web is a new high-performance ASP.NET Core middleware leveraging the ImageSharp graphics library.

Pre-release downloads are available from the MyGet package repository.

Build Status
Linux/Mac Build Status
Windows Build status

Installation

Install stable releases via Nuget; development releases are available via MyGet.

Package Name Release (NuGet) Nightly (MyGet)
SixLabors.ImageSharp.Web NuGet MyGet

Packages

  • ImageSharp.Web
    • Contains the middleware to integrate a dynamic image manipulation workflow into an ASP.NET Core application.

Once installed you will need to add the following code to ConfigureServices in your Startup.cs file.

This installs the the default service and options.

// Add the default service and options.
services.AddImageSharp();

Or add the default service and custom options.

// Add the default service and custom options.
services.AddImageSharp(
    options =>
        {
            // You only need to set the options you want to change here.
            options.Configuration = Configuration.Default;
            options.MaxBrowserCacheDays = 7;
            options.MaxCacheDays = 365;
            options.CachedNameLength = 8;
            options.OnValidate = _ => { };
            options.OnBeforeSave = _ => { };
            options.OnProcessed = _ => { };
            options.OnPrepareResponse = _ => { };
        });

Or you can fine-grain control adding the default options and configure all other services.

// Fine-grain control adding the default options and configure all other services. Setting all services is required.
services.AddImageSharpCore()
        .SetRequestParser<QueryCollectionRequestParser>()
        .SetBufferManager<PooledBufferManager>()
        .SetCache<PhysicalFileSystemCache>()
        .SetCacheHash<CacheHash>()
        .SetAsyncKeyLock<AsyncKeyLock>()
        .AddResolver<PhysicalFileSystemResolver>()
        .AddProcessor<ResizeWebProcessor>()
        .AddProcessor<FormatWebProcessor>()
        .AddProcessor<BackgroundColorWebProcessor>();

There are also factory methods for each builder that will allow building from configuration files.

// Use the factory methods to configure the PhysicalFileSystemCache
services.AddImageSharpCore(
    options =>
        {
            options.Configuration = Configuration.Default;
            options.MaxBrowserCacheDays = 7;
            options.MaxCacheDays = 365;
            options.CachedNameLength = 8;
            options.OnValidate = _ => { };
            options.OnBeforeSave = _ => { };
            options.OnProcessed = _ => { };
            options.OnPrepareResponse = _ => { };
        })
    .SetRequestParser<QueryCollectionRequestParser>()
    .SetBufferManager<PooledBufferManager>()
    .SetCache(provider =>
      {
          var p = new PhysicalFileSystemCache(
              provider.GetRequiredService<IHostingEnvironment>(),
              provider.GetRequiredService<IBufferManager>(),
              provider.GetRequiredService<IOptions<ImageSharpMiddlewareOptions>>());

          p.Settings[PhysicalFileSystemCache.Folder] = PhysicalFileSystemCache.DefaultCacheFolder;
          p.Settings[PhysicalFileSystemCache.CheckSourceChanged] = "true";

          return p;
      })
    .SetCacheHash<CacheHash>()
    .SetAsyncKeyLock<AsyncKeyLock>()
    .AddResolver<PhysicalFileSystemResolver>()
    .AddProcessor<ResizeWebProcessor>()
    .AddProcessor<FormatWebProcessor>()
    .AddProcessor<BackgroundColorWebProcessor>();

Manual build

If you prefer, you can compile ImageSharp.Web yourself (please do and help!), you'll need:

Alternatively on Linux you can use:

To clone it locally click the "Clone in Windows" button above or run the following git commands.

git clone https://github.com/SixLabors/ImageSharp.Web

How can you help?

Please... Spread the word, contribute algorithms, submit performance improvements, unit tests, no input is too little. Make sure to read our Contribution Guide before opening a PR.

The ImageSharp.Web Team

Grand High Eternal Dictator

Core Team

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

imagesharp.web's People

Contributors

daniel15 avatar jhdrn avatar jimbobsquarepants avatar sebastienros avatar tocsoft avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.