翻譯|產品更新|編輯:李顯亮|2019-08-07 11:29:03.767|閱讀 426 次
概述:近期發布了Aspose.Imaging for .NET v19.7,支持PartialRotater類中的優化策略,支持OTG(OpenDocument圖形模板),本文我們一起來探索新版中的新增功能及其工作原理。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Imaging for .NET一種高級圖像處理控件,允許開發人員創建,編輯,繪制或轉換圖像。圖像導出和轉換是API核心功能之一,它允許在不安裝Photoshop應用程序或任何其他圖像編輯器的情況下保存為AdobePhotoshop?本機格式。
近期發布了Aspose.Imaging for .NET v19.7,支持PartialRotater類中的優化策略,支持OTG(OpenDocument圖形模板),下面我們一起來探索新版中的新增功能及其工作原理。>>歡迎下載Aspose.Imaging for .NET v19.7體驗
//將文本轉換為向量對象
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());
}//為目標加載的圖像設置50兆字節的內存限制
using (var image = Image.Load(imageFilePath, new LoadOptions() { BufferSizeHint = 50 })) {
//執行RotateFlip操作
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
//執行旋轉操作
((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");
//創建字體文件夾
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); 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正版授權的朋友可咨詢哦~
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn