Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created January 31, 2024 09:04
Show Gist options
  • Save conholdate-gists/d643225c34c65837144095d5145b028c to your computer and use it in GitHub Desktop.
Save conholdate-gists/d643225c34c65837144095d5145b028c to your computer and use it in GitHub Desktop.
Crop Image Online for Free - Crop Image in C# or Java
// Load an image using the RasterImage class
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Load("aspose_logo.jpg");
// Cache the image for better performance
if (!rasterImage.IsCached)
{
rasterImage.CacheData();
}
// Set the coordinates with the Rectangle class
Aspose.Imaging.Rectangle rectangle = new Aspose.Imaging.Rectangle(35, 35, 580, 240);
// Crop the image
rasterImage.Crop(rectangle);
// Save the cropped image
rasterImage.Save("Crop-Image.jpg");
// Load an image using the RasterImage class
com.aspose.imaging.RasterImage rasterImage = (com.aspose.imaging.RasterImage)com.aspose.imaging.Image.load("aspose_logo.jpg");
// Cache the image for better performance
if (!rasterImage.isCached())
{
rasterImage.cacheData();
}
// Set the coordinates with the Rectangle class
com.aspose.imaging.Rectangle rectangle = new com.aspose.imaging.Rectangle(35, 35, 580, 240);
// Crop the image
rasterImage.crop(rectangle);
// Save the cropped image
rasterImage.save("Crop-Image.jpg");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment