Open Source .NET Library for Image Processing
Open Source .NET API for Content Aware Image Cropping Smartly.
What is SmartCrop.net?
SmartCrop.net is a free and open-source API that allows the .NET developer to crop images automatically. This is a .NET Standard port of smartcrop.js. The API is content-aware and uses a set of algorithms to crop images. The API automatically detects face by using a simple, relatively fast, small and generic algorithm. It finds the face by finding regions with a color like skin. The API implements a set of algorithms like finding regions with high-resolution, finding edges, and generates a set of candidate crops.
Getting Started with SmartCrop.net
The recommended way to install SmartCrop.net via NuGet. Please use the following command to install it.
Install SmartCrop.net via NuGet
Install-Package Smartcrop.net -Version 1.0.2-beta
Smart Crop Images via Free C# API
The open-source SmartCrop.net library allows .NET developers to smart crop images programmatically. Based on the API algorithm, the API finds high saturation areas, finds color with skin tones, and finds edges, and provides a smart guess to crop the image. By using the following code, you can easily get a smart crop for your image
Smart Crop Image in .NET
- Open image using File.OpenRead() method and pass filename
- Find the best crop using the ImageCrop(200, 200).Crop(image) method. The method takes height and width of as arguments
- Get the best crop
Crop Image in .NET
using (var image = File.OpenRead("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}");
}
});