翻譯|產(chǎn)品更新|編輯:李顯亮|2019-08-07 11:29:03.767|閱讀 423 次
概述:近期發(fā)布了Aspose.Imaging for .NET v19.7,支持PartialRotater類中的優(yōu)化策略,支持OTG(OpenDocument圖形模板),本文我們一起來(lái)探索新版中的新增功能及其工作原理。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Imaging for .NET一種高級(jí)圖像處理控件,允許開發(fā)人員創(chuàng)建,編輯,繪制或轉(zhuǎn)換圖像。圖像導(dǎo)出和轉(zhuǎn)換是API核心功能之一,它允許在不安裝Photoshop應(yīng)用程序或任何其他圖像編輯器的情況下保存為AdobePhotoshop?本機(jī)格式。
近期發(fā)布了Aspose.Imaging for .NET v19.7,支持PartialRotater類中的優(yōu)化策略,支持OTG(OpenDocument圖形模板),下面我們一起來(lái)探索新版中的新增功能及其工作原理。>>歡迎下載Aspose.Imaging for .NET v19.7體驗(yàn)
//將文本轉(zhuǎn)換為向量對(duì)象 using (Image image = Image.Load("text.psd")) { image.Save(fileName + "text_vector.pdf", new PdfOptions()); }// //老式的轉(zhuǎn)換與充分光柵化 using (Image image = Image.Load("text.psd", new PsdLoadOptions() { ReadOnlyMode = true })) { image.Save(fileName + "text_vector.pdf", new PdfOptions()); }
//為目標(biāo)加載的圖像設(shè)置50兆字節(jié)的內(nèi)存限制 using (var image = Image.Load(imageFilePath, new LoadOptions() { BufferSizeHint = 50 })) { //執(zhí)行RotateFlip操作 image.RotateFlip(RotateFlipType.Rotate90FlipNone); //執(zhí)行旋轉(zhuǎn)操作 ((RasterImage)image).Rotate(60); // rotate 60 degrees clockwise }
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 ? ".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); } }
using(Image image = Image.Load(“input.svg”)) { image.Save( “output.png”, new PngOptions() { VectorRasterizationOptions = new SvgRasterizationOptions { PageSize = image.Size, } }); }
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); }
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 (//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) gs gs8.61 bin gswin32c.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);
using(Image image = Image.Load(“input.jpg”)) { image.Save(“output.tiff”,new TiffOptions(TiffExpectedFormat.TiffJpegRgb)); }
string baseFolder = Path.Combine("D:", "test"); string fontsFolder = Path.Combine(baseFolder, "fonts"); //創(chuàng)建字體文件夾 if (!Directory.Exists(fontsFolder)) { Directory.CreateDirectory(fontsFolder); }// //復(fù)制字體到字體文件夾 string fontFile = Path.Combine(fontsFolder, "foo.ttf"); if (!File.Exists(fontFile)) { File.Copy(Path.Combine(baseFolder, "foo.ttf"), fontFile); }// //設(shè)置字體路徑 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);
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} }); }
*想要購(gòu)買Aspose.Imaging正版授權(quán)的朋友可咨詢哦~
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn