Skip to content

Geta/ImageResizer.Plugins.AutoCrop

Repository files navigation

ImageResizer.Plugins.AutoCrop

  • Master

Description

Automatic cropping for images with a flat background. Works with ImageResizer.NET 4.0.5 and above.

Uses either a relative luminance tolerance or an edge detection filter to determine which area to crop. Preserves intended aspect ratio of image.

Features

  • Crops images with a flat background
  • Configurable x and y padding
  • Configurable treshold
  • Configurable analysis method (color difference or edge detection)
  • Can override FitMode of regular resizer

How to get started?

Requires ImageResizer 4.0.5 or above

  • install-package ImageResizer.Plugins.AutoCrop

Will add the following to web.config

<configuration>
    <resizer>
        <plugins>
            <add name="AutoCrop" />
        </plugins>
    </resizer>    
</configuration>

Details

Plugin unlocks the ability to use the following query parameters for images

Parameter Description Example
autoCrop activates the plugin with the provided values ?autoCrop=10 or ?autoCrop=10;20;30
x-padding the first provided parameter value 10
y-padding the second provided parameter value 10;20
threshold the third provided parameter value, background color deviation threshold 10;20;30
autoCropMode (optional) overrides the fit mode if the autoCrop is successfully completed ?autoCropMode=pad
autoCropMethod (optional) determines which method to use (tolerance or edge) ?autoCropMethod=tolerance
autoCropDebug (optional) displays a debug visualisation of how the plugin evaluated instead of cropping ?autoCropDebug=1

Package maintainer

https://github.com/svenrog

Changelog

Changelog