Aspose.Imaging for .NET更新至最新版v20.4,实现导出为HTML5画布格式,以CDR格式实施支持文本,支持压缩矢量格式,优化针对Webp格式的速度或内存,欢迎下载体验。
Aspose.Imaging for .NET一种高级图像处理控件,允许开发人员创建,编辑,绘制或转换图像。图像导出和转换是API核心功能之一,它允许在不安装Photoshop应用程序或任何其他图像编辑器的情况下保存为AdobePhotoshop机格式。
事实证明,Aspose.Imaging是处理各种图像格式的强大API。除单页图像外,Aspose.Imaging还支持处理多页图像,包括GIF,TIFF,PSD,DICOM,CDR和WebP。
近期发布了Aspose.Imaging for .NET v20.4,实现导出为HTML5画布格式,以CDR格式实施支持文本,支持压缩矢量格式,优化针对Webp格式的速度或内存,还没使用过的朋友可以最新版Aspose.Imaging
新增与改善
key | 概述 | 类别 |
---|---|---|
IMAGINGNET-3788 | 在X3及以下版本上以CDR格式实施支持文本 | 功能 |
IMAGINGNET-3629 | 实现导出为HTML5画布格式 | 功能 |
IMAGINGNET-3413 | 允许针对Webp格式的速度或内存优化策略 | 功能 |
IMAGINGNET-3360 | 支持压缩矢量格式 | 功能 |
IMAGINGNET-3795 | Aspose.Imaging 20.2:将特定WMF转换为PNG会引发异常 | 增强功能 |
IMAGINGNET-3774 | 将EMF转换为PNG会在PNG周围添加边框 | 增强功能 |
IMAGINGNET-3770 | 无法访问已处置的对象;对象名称:“ DjvuImage” | 增强功能 |
IMAGINGNET-3679 | 从Aspose.Imaging移除PSD加载支持 | 增强功能 |
IMAGINGNET-3655 | 添加Aspose.Imaging .NET Core 3.1。组态 | 增强功能 |
新功能用法示例
IMAGINGNET-3788在X3及以下版本上以CDR格式实施支持文本
//Implemented text support in CDR versions X3 and below. string baseFolder = @"D:"; string fileName = "Placards_b.cdr"; string inputFilePath = Path.Combine(baseFolder, fileName); string outputFileName = inputFilePath + "fixed.pdf"; using (Image image = Image.Load(inputFilePath)) { PdfOptions pdfOptions = new PdfOptions(); CdrRasterizationOptions rasterizationOptions = new CdrRasterizationOptions(); rasterizationOptions.PageWidth = image.Width; rasterizationOptions.PageHeight = image.Height; pdfOptions.VectorRasterizationOptions = rasterizationOptions; image.Save(outputFileName, pdfOptions); }
IMAGINGNET-3629实现以HTML5画布格式导出
// ### What is HTML5 Canvas/ Canvas is an element in HTML5 which can be used for dynamic rendering of 2D graphics. It allows to draw pathes, boxes, texts,// images and many other things. For instance, Canvas can be // // used to draw graphs, combine photos, or create simple (or complex) diagrams.// The Canvas element is not supported in some older browsers, but is supported in recent versions of all major browsers.// Using the Canvas is not very difficult. You do not have to know HTML, JavaScript or CSS. Aspose.Imaging library will// generate all required code for you.// ### Create a simple Canvas image// Any vector image (SVG, WMF, CMX, etc.) can be used as a source for your Canvas images. The next code creates a simple Canvas image: using (var image = Image.Load(@"Sample.svg")){ image.Save(@"Canvas.html", new Html5CanvasOptions { VectorRasterizationOptions = new SvgRasterizationOptions() });} // Now you can open Canvas.html in your browser to see Canvas image.// ### HTML page structure// The Canvas image is represented by HTML page. The typical page structure is the following:// ### Add Canvas image to existing HTML page// You can embed more than one Canvas image within HTML page or update already exsiting page.// In order to do that you need to export only the Canvas tag:using (var image = Image.Load(@"Sample.svg")){ image.Save(@"Canvas.html", new Html5CanvasOptions { VectorRasterizationOptions = new SvgRasterizationOptions(), FullHtmlPage = false });}// In this case Canvas image will contain only the next content:// Now you can add this code to your existing HTML page.// ### HTML5 Canvas export options// You can modify Canvas image options during the export:// * ***CanvasTagId*** - Allows you to specify the exact Canvas tag identifier. If *CanvasTagId* is not specified,// the default identifier will be generated automatically.// * ***FullHtmlPage*** - This option determines whether the full HTML page should be generated including// the next HTML tags: *head*, *title* and *body*. The default value is *True*.// * ***Encoding*** - Specifies encoding to use during the export to the Canvas image format.// The default value is *UTF-8*.
IMAGINGNET-3360支持压缩矢量格式
// Added support for compressed vector formats Emz(compressed emf), Wmz(compressed wmf), Svgz(compressed svg). Supported read of these formats and export to other formats.1.Export compressed formats to raster string[] files = new[] {"example.emz", "example.wmz", "example.svgz"}; string baseFolder = Path.Combine("D:","Compressed"); foreach (var file in files) { string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".png"; using (Image image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = (VectorRasterizationOptions)image.GetDefaultOptions(new object[] { Color.White, image.Width, image.Height }); image.Save(outFile, new PngOptions(){VectorRasterizationOptions = vectorRasterizationOptions}); } }2.Export Emz to Emf string file = "example.emz"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".emf"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new EmfRasterizationOptions {PageSize = image.Size}; image.Save(outFile, new EmfOptions {VectorRasterizationOptions = vectorRasterizationOptions}); }3.Export Wmz to Wmf string file = "example.wmz"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".wmf"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new WmfRasterizationOptions() { PageSize = image.Size}; image.Save(outFile, new WmfOptions() {VectorRasterizationOptions = vectorRasterizationOptions}); }4.Export Svgz to Svg string file = "example.svgz"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".svg"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new SvgRasterizationOptions() { PageSize = image.Size}; image.Save(outFile, new SvgOptions() {VectorRasterizationOptions = vectorRasterizationOptions}); }5.Export Emf to Emz string file = "input.emf"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".emz"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new EmfRasterizationOptions() { PageSize = image.Size}; image.Save(outFile, new EmfOptions() {VectorRasterizationOptions = vectorRasterizationOptions, Compress = true}); }6.Export Wmf to Wmz string file = "castle.wmf"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".wmz"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new WmfRasterizationOptions() { PageSize = image.Size}; image.Save(outFile, new WmfOptions() {VectorRasterizationOptions = vectorRasterizationOptions, Compress = true}); }7.Export Svg to Svgz string file = "juanmontoya_lingerie.svg"; string baseFolder = Path.Combine("D:", "Compressed"); string inputFile = Path.Combine(baseFolder, file); string outFile = inputFile + ".svgz"; using (var image = Image.Load(inputFile)) { VectorRasterizationOptions vectorRasterizationOptions = new SvgRasterizationOptions() { PageSize = image.Size}; image.Save(outFile, new SvgOptions() {VectorRasterizationOptions = vectorRasterizationOptions, Compress = true}); }
IMAGINGNET-3679从Aspose.Imaging删除PSD加载支持
/This code throws exception as psd loading is not supported in Aspose.Imagingusing (var image = Image.Load("japan2.psd"){}//This code exports bmp image to psdusing (var image = Image.Load("tiger.bmp"){ image.Save("result.psd", new PsdOptions());}
IMAGINGNET-3413允许针对Webp格式的速度或内存优化策略
// Example 1. Setting a memory limit of 50 megabytes for operations on the created WebP imagevar imageOptions = new WebPOptions();imageOptions.Source = new FileCreateSource("created.webp", false);imageOptions.BufferSizeHint = 50;using (Image image = Image.Create(imageOptions, 1000, 1000)){// Do something with the created imageimage.Save();}// Example 2. Setting a memory limit of 20 megabytes for operations on the loaded WebP imagevar loadOptions = new LoadOptions();loadOptions.BufferSizeHint = 20;using (Image image = Image.Load("Lossless.webp", loadOptions)){// Do something with the loaded image}// Example 3. Settings a memory limit of 30 mebagytes for export-to-webp operationvar loadOptions = new LoadOptions();loadOptions.BufferSizeHint = 30;using (Image image = Image.Load("image.png", loadOptions)){image.Save("exported.webp", new WebPOptions());}
还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询。
标签:
来源:慧都
声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!