DjvuImage.Crop

Crop(Rectangle)

“Crop” trims your image to focus on specific details or remove unwanted elements, enhancing its composition and visual impact. Whether you’re adjusting photos for social media, creating website banners, or designing print materials, this tool helps you refine your images with precision and clarity.

public override void Crop(Rectangle rectangle)
ParameterTypeDescription
rectangleRectangleThe rectangle.

Examples

The following example crops a DJVU image. The cropping area is be specified via Aspose.Imaging.Rectangle.

[C#]

string dir = "c:\\temp\\";

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.djvu"))
{
    Aspose.Imaging.FileFormats.Djvu.DjvuImage djvuImage = (Aspose.Imaging.FileFormats.Djvu.DjvuImage)image;

    // Crop the image. The cropping area is the rectangular central area of the image.
    Aspose.Imaging.Rectangle area = new Aspose.Imaging.Rectangle(djvuImage.Width / 4, djvuImage.Height / 4, djvuImage.Width / 2, djvuImage.Height / 2);
    djvuImage.Crop(area);

    // Save the cropped image to PNG
    djvuImage.Save(dir + "sample.Crop.png", new Aspose.Imaging.ImageOptions.PngOptions());
}

See Also


Crop(int, int, int, int)

Crop with shifts allows you to precisely adjust the position and dimensions of the cropped area within an image. This feature is invaluable for refining compositions, aligning elements, and emphasizing focal points in your visuals. By incorporating shifts into the cropping process, you can achieve pixel-perfect precision and fine-tune the framing of your images with ease.

public override void Crop(int leftShift, int rightShift, int topShift, int bottomShift)
ParameterTypeDescription
leftShiftInt32The left shift.
rightShiftInt32The right shift.
topShiftInt32The top shift.
bottomShiftInt32The bottom shift.

See Also