softawaregmbh / smartcrop.net

A .NET Standard implementation of smartcrop.js for content aware image cropping.
MIT License
43 stars 6 forks source link

Smartcrop.net

This is a .NET Standard port of Jonas Wagner's smartcrop.js content aware image cropping library.

Usage

Install the nuget package Smartcrop.net

Add the following code:

using (var image = File.OpenRead(@"path\to\image.jpg"))
{
    // find best crop
    var result = new ImageCrop(200, 200).Crop(image);

    Console.WriteLine(
        $"Best crop: {result.Area.X}, {result.Area.Y} - {result.Area.Width} x {result.Area.Height}");
}

This is a very simple example, all the options from the original project are also available.

Sample

There is also a WPF sample project:

Screenshot of the sample project's UI Image: https://www.flickr.com/photos/endogamia/5682480447 by Leon F. Cabeiro (N. Feans), licensed under CC-BY-2.0