图像处理控件Aspose.Imaging v19.6新版亮点示例详解(2)

翻译|产品更新|编辑:李显亮|2019-07-23 11:10:16.170|阅读 62 次

概述:近期发布了Aspose.Imaging for .NET v19.6,JPEG输出中不再保留IMAGINGNET-3351 DPI属性,下面我们一起来探索新版中的新增功能及其工作原理。>>欢迎下载Aspose.Imaging for .NET v19.6体验

# 您正在找协同办公软件吗?点击这里站长给您推荐 #

相关链接:

Aspose.Imaging for .NET一种高级图像处理控件,允许开发人员创建,编辑,绘制或转换图像。图像导出和转换是API核心功能之一,它允许在不安装Photoshop应用程序或任何其他图像编辑器的情况下保存为AdobePhotoshop®本机格式。

近期发布了Aspose.Imaging for .NET v19.6,JPEG输出中不再保留IMAGINGNET-3351 DPI属性,下面我们一起来探索新版中的新增功能及其工作原理。>>欢迎下载Aspose.Imaging for .NET v19.6体验

▲JPEG输出中不保留IMAGINGNET-3351 DPI属性

string dir = "c:\\aspose.work\\IMAGINGNET\\3351\\";
 
using (Aspose.Imaging.FileFormats.Tiff.TiffImage tiffImage = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Image.Load(dir + "source2.tif"))
{
    int i = 0;
    foreach (Aspose.Imaging.FileFormats.Tiff.TiffFrame tiffFrame in tiffImage.Frames)
    {
        Aspose.Imaging.ImageOptions.JpegOptions saveOptions = new Aspose.Imaging.ImageOptions.JpegOptions();
        saveOptions.ResolutionSettings = new ResolutionSetting(tiffFrame.HorizontalResolution, tiffFrame.VerticalResolution);
 
        if (tiffFrame.FrameOptions != null)
        {
            // Set the resolution unit explicitly.
            switch (tiffFrame.FrameOptions.ResolutionUnit)
            {
                case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.None:
                    saveOptions.ResolutionUnit = ResolutionUnit.None;
                    break;
 
                case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Inch:
                    saveOptions.ResolutionUnit = ResolutionUnit.Inch;
                    break;
 
                case Aspose.Imaging.FileFormats.Tiff.Enums.TiffResolutionUnits.Centimeter:
                    saveOptions.ResolutionUnit = ResolutionUnit.Cm;
                    break;
 
                default:
                    throw new System.NotSupportedException();
            }
        }
 
        string fileName = "source2.tif.frame." + (i++) + "." + saveOptions.ResolutionUnit + ".jpg";
        tiffFrame.Save(dir + fileName, saveOptions);
    }
}


▲IMAGINGNET-3321加载PNG图像时占用大量内存

using (Image image = Image.Load("halfGigImage.png")) {
    // todo something
}


▲IMAGINGNET-3287将WMF转换为SVG时会添加边距

string dir = "c:\\aspose.work\\IMAGINGNET\\3287\\";
string fileName = dir + "image2.wmf";
 
// Save WMF to SVG
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
    // The customer uses EmfRasterizationOptions instead of WmfRasterizationOptions.
    // EmfRasterizationOptions works correctly in .NET as well.
    Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();
    rasterizationOptions.PageSize = image.Size;
 
    Aspose.Imaging.ImageOptions.SvgOptions saveOptions = new Aspose.Imaging.ImageOptions.SvgOptions();
    saveOptions.VectorRasterizationOptions = rasterizationOptions;
 
    image.Save(fileName + ".svg", saveOptions);
}                
 
// Save WMF to PNG
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(fileName))
{
    // The customer uses EmfRasterizationOptions instead of WmfRasterizationOptions.
    // EmfRasterizationOptions works correctly in .NET as well.
    Aspose.Imaging.ImageOptions.WmfRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.WmfRasterizationOptions();
    rasterizationOptions.PageSize = image.Size;
 
    Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
    saveOptions.VectorRasterizationOptions = rasterizationOptions;
 
    image.Save(fileName + ".png", saveOptions);
}


▲IMAGINGNET-3378在将WMF转换为PNG时裁剪图像宽度和高度

public void WmfToJpg() 
{
    using (Image image = Image.Load("portrt.wmf")) {
        image.Save(
                    "portrt.jpg",
                    new JpegOptions()
                        {
                            VectorRasterizationOptions = new WmfRasterizationOptions
                                                             {
                                                                 BackgroundColor = Color.WhiteSmoke,
                                                                 PageWidth = image.Width,
                                                                 PageHeight = image.Height,
                                                             }
                        });
    }
}
 
public void WmfToPngWithBorders() 
{
    using (Image image = Image.Load("portrt.wmf")) {
        image.Save(
                    "portrt.png",
                    new PngOptions()
                        {
                            VectorRasterizationOptions = new WmfRasterizationOptions
                                                             {
                                                                 BackgroundColor = Color.WhiteSmoke,
                                                                 PageWidth = image.Width,
                                                                 PageHeight = image.Height,
                                                                 BorderX = 50,
                                                                 BorderY = 20
                                                             }
                        });
    }
}


▲IMAGINGNET-3336使用ODG文件格式时,将在控制台中打印文本

string fileName = "example.odg";
using (OdgImage image = (OdgImage)Image.Load(fileName))
{
}


▲IMAGINGNET-3421 GIF文件未正确转换为PDF

public void TestExportGifToPdf() 
{
    string[] fileNames = new [] {
        "czone.gif",
        "DTRA_LogoType.gif",
        "DTRA_Seal.gif",
        "Equip1.gif",
        "Equip2.gif",
        "Equip3.gif"
    };
    foreach (string fileName in fileNames) {
        using (Image image = Image.Load(fileName))
        {
            image.Save(fileName + ".pdf", new PdfOptions());
        }
    }
}


▲IMAGINGNET-3205 RotateFlip操作与PSD无法正常工作

// RotateFlip operation doesn't work as expected with PSD
            string sourceFile = "1.psd";
            string pngPath = "RotateFlipTest2617.png";
            string psdPath = "RotateFlipTest2617.psd";
 
            RotateFlipType flipType = RotateFlipType.Rotate270FlipXY;
            using (var im = (PsdImage)(Image.Load(sourceFile)))
            {
                im.RotateFlip(flipType);
                im.Save(pngPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                im.Save(psdPath);
            }


▲IMAGINGNET-3374将DJVU格式转换为图像的问题

using (DjvuImage image = (DjvuImage)Imaging.Image.Load(@"input.djvu"))
{
PngOptions exportOptions = new PngOptions();
    for (int i = 0; i < image.Pages.Length; i++)
    {
        DjvuPage page = image.Pages[i];
        page.Save(@"page" + i + ".png", exportOptions);
    }
}


▲IMAGINGNET-3339 SvgRasterizationOptions大小设置不起作用

using (Image image = Image.Load("test.svg"))
{
    image.Save("test.svg_out.bmp",
        new BmpOptions()
        {
            VectorRasterizationOptions = new SvgRasterizationOptions()
            {
                PageWidth = 100,
                PageHeight = 200
            }
         });
}


-- 未完待续 --


*想要购买Aspose.Imaging正版授权的朋友可联系慧都客服咨询哦~

扫描关注慧聚IT微信公众号,及时获取最新动态及最新资讯

慧聚IT微信公众号




标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果

文章转载自:ASPOSE官方网站 https://docs.aspose.com/display/imagingnet/Aspose.Imaging+for+.NET+19.6+-+Release+Notes

登录 慧都网发表评论


暂无评论...

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
相关厂商
相关产品
Aspose.Imaging

Aspose.Imaging是一个可以让开发人员可以创建、编辑、画图、转换图像的图像处库,提供了一些开发平台原有功能基础之上的一些新特性。

在线
客服
在线
QQ
咨询
电话
173-8239-2642
购物车 反馈 返回
顶部
在线客服系统
live chat