Image Cropper Licensing Plugin

Contents
[ ]

         Select desired fragments and effortlessly crop images using the Image Cropper license plugin. Before you start, obtain a Metered license by providing your public and private keys using the `setMeteredKey()` method. Load your image with the supported file formats, then use the `crop()` method of the `RasterImage` class with the selected rectangle area. Finally, save the cropped image. Failure to use a licensed feature of the Aspose.Imaging graphic library will result in a watermark appearing on the output image.

import com.aspose.imaging.Image;
import com.aspose.imaging.Metered;
import com.aspose.imaging.RasterImage;
import com.aspose.imaging.Rectangle;
import com.aspose.imaging.imageoptions.JpegOptions;
import java.io.File;
//-----------------------------------------------------------------
// Crop plug-in license use examples
//-----------------------------------------------------------------
// Valid crop licensing usage example
Metered license = new Metered();
// Only metered plug-in license is supported
license.setMeteredKey("<your public key>", "<your private key>");
// get path of the input data
String templatesFolder = System.getenv("DATA_PATH");
if (templatesFolder == null)
{
templatesFolder = "c:\\Users\\USER\\Downloads\\templates\\";
}
// get output path
String outputFolder = System.getenv("OUT_PATH");
if (outputFolder == null)
{
outputFolder = templatesFolder;
}
try (RasterImage image = (RasterImage) Image.load(templatesFolder + "template.png"))
{
String filePath = outputFolder + "licensed_tiger0.jpg";
image.crop(new Rectangle(0, 0, image.getWidth() >> 1, image.getHeight() >> 1));
image.save(filePath, new JpegOptions());
new File(filePath).delete();
}
// Unlicensed use of resize with conversion license
try (RasterImage image = (RasterImage) Image.load(templatesFolder + "template.png"))
{
String filePath = outputFolder + "trial_tiger0.jpg";
image.resize(image.getWidth() << 1, image.getHeight() << 1);
image.save(filePath, new JpegOptions());
new File(filePath).delete();
}

Explore the features of our free online cropping application demo directly on our Aspose.Imaging Crop App website.