Crop image files in C# and VB.NET
With GemBox.Imaging, you can crop image files from your C# or VB.NET applications.
To crop an image using GemBox.Imaging you need to specify the desired coordinates, which are the position (x, y) and the size (width, height).
For this we will use the method image.Crop(x, y, width, height)
, with the specifications in this exact order.
The following example shows how you can easily crop image and save to various formats.

using GemBox.Imaging;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
using (var image = Image.Load("%InputFileName%"))
{
// Cropping the image
image.Crop(150, 24, 170, 260);
// Saving the cropped image
image.Save("Cropped.png");
}
}
}
Imports System
Imports GemBox.Imaging
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Using image As Image = Image.Load("%InputFileName%")
' Cropping the image
image.Crop(150, 24, 170, 260)
' Saving the cropped image
image.Save("Cropped.png")
End Using
End Sub
End Module
See also
Next steps
Published: September 14, 2022 | Modified: December 19, 2022 | Author: Ercan Görgülü