Manipulating EMF Files
Contents
[
Hide
]
Crop EMF Image
Image cropping usually refers to the removal of the outer parts of an image to help improve the framing. Cropping may also be used for to cut out some portion of an image to increase the focus on a particular area. The EmfImage class provides Crop method that accepts an instance of the Rectangle class. You can cut out any portion of an image by providing the desired boundaries to the Rectangle object.
The code snippet below demonstrates how to Crop any image by Rectangle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Imaging; | |
using Aspose.Imaging.FileFormats.Bmp; | |
using Aspose.Imaging.FileFormats.Dicom; | |
using Aspose.Imaging.FileFormats.Djvu; | |
using Aspose.Imaging.FileFormats.Emf; | |
using Aspose.Imaging.FileFormats.Eps; | |
using Aspose.Imaging.FileFormats.Eps.Consts; | |
using Aspose.Imaging.FileFormats.Jpeg; | |
using Aspose.Imaging.FileFormats.Jpeg2000; | |
using Aspose.Imaging.FileFormats.Pdf; | |
using Aspose.Imaging.FileFormats.Png; | |
using Aspose.Imaging.FileFormats.Psd; | |
using Aspose.Imaging.FileFormats.Svg; | |
using Aspose.Imaging.FileFormats.Tga; | |
using Aspose.Imaging.FileFormats.Tiff.Enums; | |
using Aspose.Imaging.ImageFilters.FilterOptions; | |
using Aspose.Imaging.ImageOptions; | |
using Aspose.Imaging.Sources; | |
using Aspose.Imaging.Xmp; | |
using Aspose.Imaging.Xmp.Schemas.Dicom; | |
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (EmfImage image = Image.Load(dataDir + "template.emf") as EmfImage) | |
{ | |
image.Crop(new Rectangle(0, 0, 30, 30)); | |
Console.WriteLine(image.Width); | |
Console.WriteLine(image.Height); | |
image.Save(dataDir + "result.emf"); | |
} | |
File.Delete(dataDir + "result.emf"); |