Crop image files

The following example shows how to use the GemBox.Imaging component to crop an image by specifying the position (x, y) and the size (width, height).

Upload your file (Drag file here)
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%"))
        {
            // Crop the image.
            image.Crop(150, 24, 170, 260);

            // Save the cropped image to a PNG file.
            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%")
			' Crop the image.
			image.Crop(150, 24, 170, 260)

			' Save the cropped image to a PNG file.
			image.Save("Cropped.png")
		End Using
	End Sub
End Module
Image file which is cropped using GemBox.Imaging
Screenshot of an image file cropped using GemBox.Imaging

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