Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 1.05 KB

README.md

File metadata and controls

29 lines (19 loc) · 1.05 KB

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