彩票走势图

图像处理控件Aspose.Imaging v20.8 三大新功能上线!增强EPS格式支持

原创|产品更新|编辑:李显亮|2020-08-27 09:45:38.890|阅读 176 次

概述:Aspose.Imaging for .NET更新至最新版v20.8,实现从TIFF图像中的Path资源创建GraphicsPath的功能,增强EPS格式支持,支持加载和转换EPS文件PDF / A格式,支持本机导出栅格-HTML5 Canvas等,欢迎下载体验。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

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

事实证明,Aspose.Imaging是处理各种图像格式的强大API。除单页图像外,Aspose.Imaging还支持处理多页图像,包括GIF,TIFF,PSD,DICOM,CDR和WebP。

近期发布了Aspose.Imaging for .NET v20.8,实现从TIFF图像中的Path资源创建GraphicsPath的功能,增强EPS格式支持,支持加载和转换EPS文件PDF / A格式,支持本机导出栅格-HTML5 Canvas等,还没使用过的朋友可以点击下载最新版Aspose.Imaging

好消息来啦!整合所有格式API处理控件Aspose永久授权正在慧都网火热销售中,新购乐享85折起!立马1分钟了解全部咨询!

新增与改善

key 概述 类别
IMAGINGNET-3989 实现从TIFF图像中的Path资源创建GraphicsPath的能力,反之亦然 功能
IMAGINGNET-3732 增强EPS格式支持 功能
IMAGINGNET-2243 支持加载和转换EPS文件PDF / A格式 功能
IMAGINGNET-4045 PSD导出器不支持压缩方法 增强功能
IMAGINGNET-4033 调整PNG大小并保存为JPG后黑色输出 增强功能
IMAGINGNET-4016 使用RLE压缩导出到BMP时输出不正确 增强功能
IMAGINGNET-4011 WebPOptions.Quality属性不影响导出期间WebP图像压缩的程度 增强功能
IMAGINGNET-3995 呈现WMF文件时引发“文件已损坏或损坏”异常 增强功能
IMAGINGNET-3994 支持本机导出栅格-HTML5 Canvas 增强功能
IMAGINGNET-3985 根据Aspose.Psd调整大小实施其他调整大小方法 增强功能
IMAGINGNET-3982 通过TIFF的像素读取打开LoadRawData中的异常 增强功能
IMAGINGNET-3981 逐行读取TIFF的LoadRawData中的异常 增强功能
IMAGINGNET-3977 加载webp图像时异常 增强功能
IMAGINGNET-3974 保存JP2时,对象引用未设置为对象异常的实例 增强功能
IMAGINGNET-3973 保存ODG时未定义的函数“ if”异常 增强功能
IMAGINGNET-3867 在VectorImageExporter中支持剪切操作 增强功能
IMAGINGNET-3843 Aspose.Imaging 20.3:尝试将特定的Emf转换为光栅图像时发生异常 增强功能
IMAGINGNET-3748 WMF图像在导出的PDF的右侧被剪切 增强功能
IMAGINGNET-2981 转换EPS的异常 增强功能

用法示例

IMAGINGNET-4045 PSD导出器不支持压缩方法

// When exporting to PSD, options for compression, color type and bitness are available:

using (Image image = Image.Load(SRC)) 
{
 // Export to PSD with RLE compression
 image.Save(DEST1, new PsdOptions() { 
  CompressionMethod = CompressionMethod.RLE 
 });

 // Export to PSD with RGB color type
 image.Save(DEST2, new PsdOptions() { 
  ColorMode = ColorModes.Rgb, 
  ChannelsCount = 3, 
  ChannelBitsCount = 8 
 });

 // Export to PSD with ARGB color type
 image.Save(DEST3, new PsdOptions() { 
  ColorMode = ColorModes.Rgb, 
  ChannelsCount = 4, 
  ChannelBitsCount = 8 
 });

 // Export to PSD with Grayscale color type
 image.Save(DEST4, new PsdOptions() { 
  ColorMode = ColorModes.Grayscale, 
  ChannelsCount = 1, 
  ChannelBitsCount = 8 
 });

 // Export to PSD with Monochrome color type
 image.Save(DEST5, new PsdOptions() { 
  ColorMode = ColorModes.Bitmap, 
  ChannelsCount = 1, 
  ChannelBitsCount = 1 
 });

 // Export to PSD with Indexed color type
 image.Save(DEST6, new PsdOptions() { 
  ColorMode = ColorModes.Indexed, 
  ChannelsCount = 1, 
  ChannelBitsCount = 8, 
  Palette = ColorPaletteHelper.Create8Bit() 
 });
}

IMAGINGNET-4033调整PNG大小并保存为JPG后黑色输出

using (Image image = Image.Load("image01-100MB.png"))
{
    image.Resize(600, 400);
    image.Save("output.jpg", new JpegOptions());
}

IMAGINGNET-3994支持本机导出栅格-HTML5 Canvas

将栅格图像导出为HTML5 Canvas格式,您可以轻松地将任何光栅图像(动画除外)导出为HTML5 Canvas图像格式。以下代码演示了如何导出为HTML5 Canvas格式:

using (var image = Image.Load("tiger.bmp"))
{
    image.Save("tiger.html", new Html5CanvasOptions());
}

IMAGINGNET-3989实现从TIFF图像中的Path资源创建GraphicsPath的功能,反之亦然

从TIFF图像中的路径资源创建图形路径。您可以在TIFF图像中使用路径资源来创建GraphicsPath类实例。GraphicsPath可以与Graphics类一起使用以在图像上绘制。下一个源代码示例显示了如何创建GraphicsPath实例,然后在图像上画一条红线〜:

using (var image = (TiffImage)Image.Load("Bottle.tif"))
{
    // Create the GraphicsPath using PathResources from TIFF image
    var graphicsPath = PathResourceConverter.ToGraphicsPath(image.ActiveFrame.PathResources.ToArray(), image.ActiveFrame.Size);
    var graphics = new Graphics(image);

    // Draw red line and save the image
    graphics.DrawPath(new Pen(Color.Red, 10), graphicsPath);
    image.Save("BottleWithRedBorder.tif");
}

// Create Path Resources using Graphics Path¶
// Its also possible to create the Path Resources using Graphics Path. The next source code sample 
// demonstrates how you can accomplish that:

static void Main(string[] args)
{
    using (var image = (TiffImage)Image.Load("Bottle.tif"))
    {
        // Create rectangular Figure for GraphicsPath
        var figure = new Figure();
        figure.AddShape(CreateBezierShape(100f, 100f, 500f, 100f, 500f, 1000f, 100f, 1000f));

        // Create GraphicsPath using our Figure
        var graphicsPath = new GraphicsPath();
        graphicsPath.AddFigure(figure);

        // Set PathResources using GraphicsPath
        var pathResouze = PathResourceConverter.FromGraphicsPath(graphicsPath, image.Size);
        image.ActiveFrame.PathResources = new List(pathResouze);

        // Save the image
        image.Save("BottleWithRectanglePath.tif");
    }
}

private static BezierShape CreateBezierShape(params float[] coordinates)
{
    var bezierPoints = CoordinatesToBezierPoints(coordinates).ToArray();
    return new BezierShape(bezierPoints, true);
}

private static IEnumerableCoordinatesToBezierPoints(float[] coordinates)
{
    for (var coordinateIndex = 0; coordinateIndex < coordinates.Length; coordinateIndex += 2) for (var index = 0; index < 3; index++) yield return new PointF(coordinates[coordinateIndex], coordinates[coordinateIndex + 1]); }

IMAGINGNET-3732增强EPS格式支持

### What is EPS image format?

EPS file format is short for Encapsulated PostScript. It was created by Adobe back in 1992. It's a standard graphics file format intended for placing images or drawings within a PostScript Document. Basically it's a postscript program saved as a single file. EPS file also includes a low-resolution preview of the graphics inside which makes it accessible with programs not capable of editing the script inside. EPS file format is widely used by publishers because of its compatibility across different operating systems.

An EPS file can contain any combination of text, graphics, and images. Since it is actually a PostScript file, it is one of the most versatile file formats that are available. The files are supported by several different drawing programs and vector graphic editing applications. Many image converter programs can create EPS files containing the pixels of the image. An EPS file is a stream of generic PostScript printing commands. Thus many PostScript printer drivers have an option to save as EPS.

### The image preview

EPS files can optionally contain a bitmapped image preview so that systems that can't render PostScript directly can at least display a crude representation of what the graphic will look like. There are 4 preview formats: PICT, TIFF, Metafile and EPSI. It is also possible to have an EPS file without a preview, though. In this case, the imported file is usually displayed as a grayed out box or a box with diagonal lines running through it.

The preview image has a fixed resolution, which is usually 72 dpi. If you enlarge an EPS file in a document, the preview image is stretched and may become ‘blocky' and lacking in detail. This does not necessarily mean that the EPS-data themselves will degrade in quality. As long as the EPS-file only contains text and vector graphics, scaling it does not affect its quality. If you print a file containing an EPS-image on a non-PostScript printer, it is usually the preview image that gets printed. The preview image is ignored when you print to a PostScript device.

### Convert EPS image to PNG
The following code converts EPS image to PNG. The property **PreviewToExport** allows to select the source of the image to export from EPS file. The value **PostScriptRendering** of the enumeration **EpsPreviewFormat** cause rendering from PostScript to raster image.

using (var image = (EpsImage)Image.Load("Sample.eps"))
{
    var options = new PngOptions
    {
        VectorRasterizationOptions = new EpsRasterizationOptions
        {
            PageWidth = 500, // Image width
            PageHeight = 500 // Image height
        }
    };

    image.PreviewToExport = EpsPreviewFormat.PostScriptRendering; // Render raster image using the PostScript
    image.Save("Sample.png", options);
}

### Convert EPS to other formats
*Aspose.Imaging* library allows you to export EPS image to other formats. For that you just need to use corresponding Image options. The following code demonstrates how to export EPS image to PDF:

using (var image = (EpsImage)Image.Load("Sample.eps"))
{
    var options = new PdfOptions
    {
        PdfCoreOptions = new PdfCoreOptions
        {
            PdfCompliance = PdfComplianceVersion.PdfA1b // Set required PDF compliance
        }
    };

    image.PreviewToExport = EpsPreviewFormat.PostScriptRendering;
    image.Save("Sample.pdf", options);
}

### Determine whether the EPS image has a preview
As we already discussed, EPS image can contain an encapsulated preview image. The following code shows how can you determine if the preview exists:

using (var image = (EpsImage)Image.Load("Sample.eps"))
{
    if (image.HasRasterPreview)
    {
        Console.WriteLine("The image has a raster preview.");
    }
}

### Export EPS preview image without PostScript rendering
There are several ways how can you export EPS preview image. The following code exports TIFF preview image:

using (var image = (EpsBinaryImage)Image.Load("Sample.eps"))
{
    // Tiff image export options
    var options = new TiffOptions(TiffExpectedFormat.TiffJpegRgb)

    // The first way:
    image.TiffPreview.Save("Sample1.tiff", options);

    // The second way:
    image.PreviewToExport = EpsPreviewFormat.TIFF;
    image.Save("Sample2.tiff", options);
}

IMAGINGNET-2243-支持加载和转换EPS文件PDF / A格式

以下代码演示了如何将EPS图像导出为PDF:

using (var image = (EpsImage)Image.Load("Sample.eps"))
{
    var options = new PdfOptions
    {
        PdfCoreOptions = new PdfCoreOptions
        {
            PdfCompliance = PdfComplianceVersion.PdfA1b // Set required PDF compliance
        }
    };

    image.PreviewToExport = EpsPreviewFormat.PostScriptRendering;
    image.Save("Sample.pdf", options);
}

还想要更多吗?您可以点击阅读
【2020 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(642018183),我们很高兴为您提供查询和咨询

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP