Devesprit.ImageProcessor & Devesprit.ImageServer
Crop

Description:

Crops the current image to the given location and size. There are two modes available:

  1. Pixel based - Supply the upper-left coordinates and the new width/height.
  2. Percentage based - Supply the left, top, right, and bottom percentages as a decimal between 0 and 1 to crop with an indicator to switch mode.
Method Declaration
Copy Code
public ImageFactory Crop(Rectangle rectangle)

Rectangle:

rectangle

The System.Drawing.Rectangle containing the coordinates to crop the image to.




Method Declaration
Copy Code
public ImageFactory Crop(CropLayer cropLayer)

CropLayer:

Left

The System.Float defining the left coordinate of the crop layer to offset from the original image. When the crop mode is defined as CropMode.Percentage this becomes the percentage you want to remove from the left hand side of the image.

Top

The System.Float defining the top coordinate of the crop layer to offset from the original image. When the crop mode is defined as CropMode.Percentage this becomes the percentage you want to remove from the top of the image.

Right

The System.Float defining the width of the crop layer. When the crop mode is defined as CropMode.Percentage this becomes the percentage you want to remove from the right hand side of the image.

Bottom

The System.Float defining the height of the crop layer. When the crop mode is defined as CropMode.Percentage this becomes the percentage you want to remove from the bottom of the image.

CropMode

The ImageProcessor.Imaging.CropMode to determine how to perform the crop.

Assembly:

Devesprit.ImageProcessor

Example
Copy Code
new ImageFactory().Load(@"My-Image-Path").Crop(new CropLayer(10,10,30,30, CropMode.Percentage));

Original

 

 

Result