近期发布了Aspose.Imaging for .NET v19.7,支持PartialRotater类中的优化策略,支持OTG(OpenDocument图形模板),下面我们一起来探索新版中的新增功能及其工作原理。>>欢迎下载Aspose.Imaging for .NET v19.7体验
▲IMAGINGNET-2926 – 将PSD保存到PDF中不提供可选择的文本
//将文本转换为向量对象using (Image image = Image.Load("text.psd")){ image.Save(fileName + "text_vector.pdf", new PdfOptions());}////老式的转换与充分光栅化using (Image image = Image.Load("text.psd", new PsdLoadOptions() { ReadOnlyMode = true })){ image.Save(fileName + "text_vector.pdf", new PdfOptions());}
▲IMAGINGNET-3381 – 在PartialRotater类中支持优化策略
//为目标加载的图像设置50兆字节的内存限制using (var image = Image.Load(imageFilePath, new LoadOptions() { BufferSizeHint = 50 })) { //执行RotateFlip操作 image.RotateFlip(RotateFlipType.Rotate90FlipNone);//执行旋转操作 ((RasterImage)image).Rotate(60); // rotate 60 degrees clockwise}
▲IMAGINGNET-2044 – 支持OTG (OpenDocument图形模板)
string baseFolder = "D:"; string fileName = "VariousObjectsMultiPage.otg"; ImageOptionsBase[] options = { new PngOptions(), new PdfOptions() }; foreach (ImageOptionsBase item in options) { string inputFileName = Path.Combine(baseFolder, fileName); string fileExt = item is PngOptions nbsp;".png" : ".pdf"; string outputFileName = Path.Combine(baseFolder, fileName + fileExt); using (Image image = Image.Load(inputFileName)) { OtgRasterizationOptions otgRasterizationOptions = new OtgRasterizationOptions(); otgRasterizationOptions.PageSize = image.Size; item.VectorRasterizationOptions = otgRasterizationOptions; image.Save(outputFileName, item); } }
▲IMAGINGNET-3442 – Bpmn.io SVG转换导致陌生的PNG
using(Image image = Image.Load(“input.svg”)){ image.Save( “output.png”, new PngOptions() { VectorRasterizationOptions = new SvgRasterizationOptions { PageSize = image.Size, } }); }
▲IMAGINGNET-3430 – 支持PDFOptions中的DPI设置
string baseFolder =“D:”; string fileName =“standardSize.tif”; string inputFileName = Path.Combine(baseFolder,fileName); string outFileName = inputFileName +“。pdf”; using(Image image = Image.Load(inputFileName)) { PdfOptions pdfOptions = new PdfOptions {PageSize = new SizeF(612,792 )}; image.Save(outFileName,pdfOptions); }
▲IMAGINGNET-3286 – 没有从WMF到SVG的真正转换
string baseFolder = Path.Combine("D:","3286"); string fileName = "image2.wmf"; string inputFileName = Path.Combine(baseFolder, fileName); using (Image image = Image.Load(inputFileName)) { string script = ((WmfImage)image).GetPostScript(); string ethlonScript = File.ReadAllText(inputFileName + ".ps"); if (script != ethlonScript) { throw new Exception("script not eqal ethalon script"); } }Since PostScript is not supported in Aspose products, further processing is done by **third-party applications**.For example:Use ghostscript (https://ghostscript.com/) string baseFolder = Path.Combine("D:","3286"); string fileName = "image2.wmf"; string inputFileName = Path.Combine(baseFolder, fileName); string scriptFileName = inputFileName + ".ps"; string outputPdfFileName = scriptFileName + ".pdf"; string ghostPath = "C:Program Files (x86)gsgs8.61bingswin32c.exe"; string script; using (Image image = Image.Load(inputFileName)) { script = ((WmfImage)image).GetPostScript(); } File.WriteAllText(scriptFileName, script); string cmdArguments = string.Format(" -sDEVICE=pdfwrite -o {0} {1}", outputPdfFileName, scriptFileName); Process proc = System.Diagnostics.Process.Start(ghostPath, cmdArguments); proc.WaitForExit(60000);
▲IMAGINGNET-3230 – 将Jpeg转换为Tiff会导致绿色覆盖不正确
using(Image image = Image.Load(“input.jpg”)){ image.Save(“output.tiff”,new TiffOptions(TiffExpectedFormat.TiffJpegRgb)); }
▲IMAGINGNET-3445 – 来自font文件夹的文件被锁定
string baseFolder = Path.Combine("D:", "test"); string fontsFolder = Path.Combine(baseFolder, "fonts"); //创建字体文件夹 if (!Directory.Exists(fontsFolder)) { Directory.CreateDirectory(fontsFolder); }// //复制字体到字体文件夹 string fontFile = Path.Combine(fontsFolder, "foo.ttf"); if (!File.Exists(fontFile)) { File.Copy(Path.Combine(baseFolder, "foo.ttf"), fontFile); }// //设置字体路径 List fonts = new List(FontSettings.GetDefaultFontsFolders()); fonts.Add(fontsFolder); FontSettings.SetFontsFolders(fonts.ToArray(), true);// //打开图片 string inputFile = Path.Combine(baseFolder, "grinched-regular-font.psd"); string outputFile = inputFile + ".png"; using (Image image = Image.Load(inputFile)) { PngOptions saveOptions = new PngOptions(); image.Save(outputFile, saveOptions); } //删除字体文件夹 Directory.Delete(fontsFolder,true);
▲IMAGINGNET-3444 – 用于调整SVG图像大小的Aspose.Imaging问题
string baseFolder = "D:"; string inputFileName = Path.Combine(baseFolder, "logotype.svg"); float scale = 10f; using (Image image = Image.Load(inputFileName)) { image.Save(inputFileName+".png", new PngOptions() { VectorRasterizationOptions = new SvgRasterizationOptions() {PageSize = image.Size, ScaleX = scale, ScaleY = scale} }); }
*想要购买Aspose.Imaging正版授权的朋友可联系客服咨询哦~
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!