This is a .NET Standard port of Jonas Wagner's smartcrop.js content aware image cropping library.
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.
There is also a WPF sample project:
Image: https://www.flickr.com/photos/endogamia/5682480447 by Leon F. Cabeiro (N. Feans), licensed under CC-BY-2.0