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

c# code to compress pdf, how to add header and footer in pdf using itextsharp in c# with example, pdf generator, itextsharp add image to pdf, c# pdf reader writer, qr code reader using webcam c#.

Related .net document control helps: display tiff images: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control mvc pdf editor control: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC image viewer jquery: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery office document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications pdf editor component: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents view text file: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET dicom web 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. c# convert pdf to text file, c# pdf printing library, how to rotate a pdf in c#, password protect pdf file, c# pdfsharp fill pdf form, convert pdf to text file, byte array to pdf in c#.

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.

free pdf preview in asp net c#, asp net replace text fro pdf free, tiff image viewer, mvc pdf viewer control, display pdf, how to edit pdf file in c#, display excel spreadsheet.

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);