Image Cropper Licensing Plugin
Effortlessly select desired fragments and crop images using the Image Cropper license plugin. Before beginning, secure a Metered license by providing your public key and private password using the `SetMeteredKey()` method. Load your image with file format from the list of supported formats, then apply the 'Crop()' method of the `RasterImage` class with the chosen rectangle area. Finally, save the resulting image. Utilizing an unlicensed feature of the Aspose.Imaging graphic library will result in a watermark appearing on the output image.
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Tiff; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Sources; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
Run2(); | |
//----------------------------------------------------------------- | |
// Crop plug-in license use examples | |
//----------------------------------------------------------------- | |
void Run2() | |
{ | |
// Valid crop licesing usage example | |
Metered license = new Metered(); | |
// Only metered plug-in license is supported | |
license.SetMeteredKey("<your public key>", "<your private key>"); | |
string OutputDirectory = templatesFolder; | |
using (var image = (RasterImage)Image.Load(Path.Combine(templatesFolder, "template.png"))) | |
{ | |
var filePath = Path.Combine(OutputDirectory, "licensed_tiger0.jpg"); | |
image.Crop(new Rectangle(0, 0, image.Width >> 1, image.Height >> 1)); | |
image.Save(filePath, new JpegOptions()); | |
File.Delete(filePath); | |
} | |
// Unlicensed use of resize with crop license | |
using (Image image = Image.Load(Path.Combine(templatesFolder, "template.png"))) | |
{ | |
var filePath = Path.Combine(OutputDirectory, "trial_tiger0.jpg"); | |
image.Resize(image.Width << 1, image.Height << 1); | |
image.Save(filePath, new JpegOptions()); | |
File.Delete(filePath); | |
} | |
} |
Discover the capabilities of our free online cropping application demo directly on our Aspose.Imaging Crop App website.