Deskew image

Contents
[ ]

Deskew image

Skew is an artifact that might appear during document scanning process and it consists of getting the document’s text/images be rotated at a slight angle. It can have various causes but the most common are paper getting misplaced during a scan. Therefore, deskew is the process of detecting and fixing this issue on scanned files (ie, bitmap) so deskewed images will have the text/images correctly and horizontally aligned.

using Aspose.Imaging;
using System.IO;
string templatesFolder = @"c:\Users\USER\Downloads\templates\";
string dataDir = templatesFolder;
// Get rid of the skewed scan with default parameters
using (RasterImage image = (RasterImage)Image.Load(dataDir + "template.jpg"))
{
image.NormalizeAngle(false /*do not resize*/, Color.LightGray /*background color*/);
image.Save(Path.Combine(dataDir, "result.jpg"));
}
File.Delete(dataDir + "result.jpg");
view raw deskew-image.cs hosted with ❤ by GitHub