How to C#: Imaging
Using Imaging SDK for C#.NET
Winforms Controls
Image Load
Image Access and Modify
Geometry: Crop
Geometry: Crop
Home ›› XImage.Raster ›› C# Raster: Crop Image according to Specified Size

How to C#: Crop Image according to Specified Size

Guide for How to Crop Image

Related .net document control helps: pdf file permission: ASP.NET PDF File Permission Control: apply, remove PDF file permission settings in C# create pdf: ASP.NET Create PDF Document Control: create, convert PDF file from Word, Excel, Tiff file formats in C# ASP.NET word file viewer: ASP.NET Office Word Document Viewer: view MS Office Word files online using C# in ASP.NET web applications dnn document viewer: DNN Document Viewer Control: view, annotate, redact, convert documents in dotnetnuke ASP.NET
document annotation ASP.NET Document Annotation Control: text comment, drawing on files online using ASP.NET component text document viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET

Steps to Crop image with specific Region

Load an image with RasterImage object.

Create an image processor with ImageProcess object.

Call the method CropImage of ImageProcess object to complete the task croping image.

Save the croped image to an image file on the disk.

If you want to have a try, please refer to the following steps.

Install XImage.Raster in C# Project

Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;




Use corresponding namespaces;

  using RasterEdge.XImage.Raster;

Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:


       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.


       If using x86, the platform target should be x86.

Crop Image Size

By using the XImage.Raster SDK, you can crop the current image to the specified valid size.

Sample Code (crop current image to specified size):

RasterImage img = new RasterImage(@"C:\input.tif");
ImageProcess process = new ImageProcess(img);
//Crop the image to the specified size, X coordinate is 10, Y coordinate is 20, and the target size is 200x200.
process.CropImage(new Rectangle(10, 20, 200, 200));
//If the tiff image has multiple pages,
//it will only crop the second page of the input tif
process.CropImage(new Rectangle(10, 20, 200, 200), 1);