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.

Image file which is cropped using GemBox.Imaging
Screenshot of an image file cropped using GemBox.Imaging
Upload your file (Drag file here)
using GemBox.Imaging;

class Program
    static void Main()
        // If using the Professional version, put your serial key below.

        using (var image = Image.Load("%InputFileName%"))
            // Cropping the image
            image.Crop(150, 24, 170, 260);

            // Saving the cropped image
Imports System
Imports GemBox.Imaging

Module Program

	Sub Main()

		' If using Professional version, put your serial key below.
		Using image As Image = Image.Load("%InputFileName%")
			' Cropping the image
			image.Crop(150, 24, 170, 260)

			' Saving the cropped image
		End Using
	End Sub
End Module

See also

Next steps

GemBox.Imaging is a .NET component that provides an easy way to load, edit, save images. GemBox.Imaging also supports file format conversions and image transformations (resize, crop, rotate and flip).

Download Buy