彩票走势图

PSD文件处理API-Aspose.PSD v20.6新功能推荐!支持LnkE资源和文档转换进度浏览

翻译|产品更新|编辑:李显亮|2020-07-03 10:43:31.740|阅读 349 次

概述:Aspose.PSD for .Net更新至新版本v20.6,支持LnkE资源,支持britResource(亮度/对比度调整层资源),同时将DefaultReplacementFont设置移到ImageOptionsBase类中,欢迎下载体验。

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

Aspose.PSD for .Net是高级PSD和入门级AI文件格式操作API,允许创建和编辑Photoshop文件,并提供更新图层属性,添加水印,执行图形操作或将一种文件格式转换为另一种文件的功能,没有任何Adobe Photoshop或Adobe Illustrator依赖项。

令人兴奋的是,.NET版Aspose.PSD迎来了6月的最新更新!新增了如下两大新功能:

  • 支持LnkE资源
  • 支持britResource(亮度/对比度调整层资源)

>>你可以点击这里下载Aspose.PSD for .NET v20.6测试体验


具体更新内容

key 概述 类别
PSDNET-606 支持LnkE资源 新功能
PSDNET-386 支持britResource(亮度/对比度调整层资源) 新功能
PSDNET-219 将DefaultReplacementFont设置移到ImageOptionsBase类中 增强功能
PSDNET-596 没有渲染没有通过穿透混合模式的图层组 Bug修复
PSDNET-610 尝试将特定的Psd文件转换为图像时出现NullReference异常 Bug修复
PSDNET-636 如果调整图层中的蒙版具有空白边界,则调整PSD文件的大小将无法正常工作 Bug修复
PSDNET-611 尝试打开特定的Psd文件时发生OverflowException Bug修复
PSDNET-565 具有RGB模式16位/通道的Psd图像仅在预览时更新图层 Bug修复
PSDNET-652 使用复合LnkE资源和adobeStockLicenseState属性加载特定PSD文件时发生异常 Bug修复
PSDNET-640 PSD图层蒙版更改在保存时被丢弃 Bug修复
PSDNET-593 将AI文件保存为Jpeg2000格式不起作用 Bug修复
PSDNET-638 将图层组添加到空图层组后,图层顺序不正确 Bug修复

PSDNET-606-支持LnkE资源

string message = "ExampleOfLnkEResourceSupport works incorrectly.";
void AssertIsTrue(bool condition)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}
 
void AssertAreEqual(object actual, object expected)
{
    if (!object.Equals(actual, expected))
    {
        throw new FormatException(message);
    }
}
 
// This example demonstrates how to get and set properties of the Photoshop Psd LnkE Resource that contains information about an external linked file.
void ExampleOfLnkEResourceSupport(
    string filePath,
    int length,
    int length2,
    int length3,
    int length4,
    string fullPath,
    string date,
    double assetModTime,
    string childDocId,
    bool locked,
    string uid,
    string name,
    string originalFileName,
    string fileType,
    long size)
{
    string fileName = Path.GetFileName(filePath);
    string outputPath = @"Output\" + fileName;
    using (PsdImage image = (PsdImage)Image.Load(filePath))
    {
        LnkeResource lnkeResource = null;
        foreach (var resource in image.GlobalLayerResources)
        {
            lnkeResource = resource as LnkeResource;
            if (lnkeResource != null)
            {
                AssertAreEqual(lnkeResource.Length, length);
                AssertAreEqual(lnkeResource.UniqueId, new Guid(uid));
                AssertAreEqual(lnkeResource.FullPath, fullPath);
                AssertAreEqual(lnkeResource.Date.ToString(CultureInfo.InvariantCulture), date);
                AssertAreEqual(lnkeResource.AssetModTime, assetModTime);
                AssertAreEqual(lnkeResource.AssetLockedState, locked);
                AssertAreEqual(lnkeResource.FileName, name);
                AssertAreEqual(lnkeResource.FileSize, size);
                AssertAreEqual(lnkeResource.ChildDocId, childDocId);
                AssertAreEqual(lnkeResource.Version, 7);
                AssertAreEqual(lnkeResource.FileType, fileType);
                AssertAreEqual(lnkeResource.FileCreator, string.Empty);
                AssertAreEqual(lnkeResource.OriginalFileName, originalFileName);
                AssertAreEqual(lnkeResource.CompId, -1);
                AssertAreEqual(lnkeResource.OriginalCompId, -1);
                AssertIsTrue(lnkeResource.HasFileOpenDescriptor);
                AssertIsTrue(!lnkeResource.IsEmpty);
                AssertIsTrue(lnkeResource.Type == LinkResourceType.liFE);
 
                lnkeResource.FullPath =
                    @"file:///C:/Aspose/net/Aspose.Psd/test/testdata/Images/Psd/SmartObjects/rgb8_2x2.png";
                AssertAreEqual(lnkeResource.Length, length2);
                lnkeResource.FileName = "rgb8_2x23.png";
                AssertAreEqual(lnkeResource.Length, length3);
                lnkeResource.ChildDocId = Guid.NewGuid().ToString();
                AssertAreEqual(lnkeResource.Length, length4);
                lnkeResource.Date = DateTime.Now;
                lnkeResource.AssetModTime = double.MaxValue;
                lnkeResource.FileSize = long.MaxValue;
                lnkeResource.FileType = "test";
                lnkeResource.FileCreator = "file";
                lnkeResource.CompId = int.MaxValue;
                break;
            }
        }
 
        AssertIsTrue(lnkeResource != null);
 
        image.Save(outputPath, new PsdOptions(image));
    }
 
    using (PsdImage image = (PsdImage)Image.Load(outputPath))
    {
        image.Save(
            Path.ChangeExtension(outputPath, "png"),
            new PngOptions
            {
                ColorType = PngColorType.TruecolorWithAlpha
            });
    }
}
 
// This example demonstrates how to get and set properties of the Psd LnkE Resource that contains information about external linked JPEG file.
this.ExampleOfLnkEResourceSupport(
    @"..\..\..\Issues\IMAGINGNET-2375\photooverlay_5_new.psd",
    0x21c,
    0x26c,
    0x274,
    0x27c,
    @"file:///C:/Users/cvallejo/Desktop/photo.jpg",
    "05/09/2017 22:24:51",
    0,
    "F062B9DB73E8D124167A4186E54664B0",
    false,
    "02df245c-36a2-11e7-a9d8-fdb2b61f07a7",
    "photo.jpg",
    "photo.jpg",
    "JPEG",
    0x1520d);
 
// This example demonstrates how to get and set properties of the PSD LnkE Resource that contains information about an external linked PNG file.
this.ExampleOfLnkEResourceSupport(
    "rgb8_2x2_linked.psd",
    0x284,
    0x290,
    0x294,
    0x2dc,
    @"file:///C:/Aspose/net/Aspose.Psd/test/testdata/Issues/PSDNET-491/rgb8_2x2.png",
    "04/14/2020 14:23:44",
    0,
    "",
    false,
    "5867318f-3174-9f41-abca-22f56a75247e",
    "rgb8_2x2.png",
    "rgb8_2x2.png",
    "png",
    0x53);
 
// This example demonstrates how to get and set properties of the Photoshop Psd LnkE Resource that contains information about an external linked CC Libraries Asset.
this.ExampleOfLnkEResourceSupport(
    "rgb8_2x2_asset_linked.psd",
    0x398,
    0x38c,
    0x388,
    0x3d0,
    @"CC Libraries Asset “rgb8_2x2_linked/rgb8_2x2” (Feature is available in Photoshop CC 2015)",
    "01/01/0001 00:00:00",
    1588890915488.0d,
    "",
    false,
    "ec15f0a8-7f13-a640-b928-7d29c6e9859c",
    "rgb8_2x2_linked",
    "rgb8_2x2.png",
    "png",
    0);

PSDNET-201-支持文档转换进度

string sourceFilePath = "Apple.psd";
Stream outputStream = new MemoryStream();
 
ProgressEventHandler localProgressEventHandler = delegate(ProgressEventHandlerInfo progressInfo)
{
      string message = string.Format(
           "{0} {1}: {2} out of {3}",
           progressInfo.Description,
           progressInfo.EventType,
           progressInfo.Value,
           progressInfo.MaxValue);
      Console.WriteLine(message);
};
 
Console.WriteLine("---------- Loading Apple.psd ----------");
var loadOptions = new PsdLoadOptions() { ProgressEventHandler = localProgressEventHandler };
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath, loadOptions))
{
      Console.WriteLine("---------- Saving Apple.psd to PNG format ----------");
      image.Save(
           outputStream,
           new PngOptions()
           {
                 ColorType = PngColorType.Truecolor, ProgressEventHandler = localProgressEventHandler
           });
 
      Console.WriteLine("---------- Saving Apple.psd to PSD format ----------");
      image.Save(
           outputStream,
           new PsdOptions()
           {
                 ColorMode = ColorModes.Rgb,
                 ChannelsCount = 4,
                 ProgressEventHandler = localProgressEventHandler
           });
}

PSDNET-386-支持britResource(亮度/对比度调整层资源)

/* This Example demonstrates how you can programmatically change the PSD Image Brightness/Contrast Layer Resource - BritResource
   This is a Low-Level Aspose.PSD API. You can use Brightness/Contrast Layer through its API, which will be much easier, 
   but direct PhotoShop resource editing gives you more control over the PSD file content.  */
string path = @"BrightnessContrastPS6.psd";
string outputPath = @"BrightnessContrastPS6_output.psd";
using (PsdImage im = (PsdImage)Image.Load(path))
{
    foreach (var layer in im.Layers)
    {
        if (layer is BrightnessContrastLayer)
        {
            foreach (var layerResource in layer.Resources)
            {
                if (layerResource is BritResource)
                {
                    var resource = (BritResource)layerResource;
                    isRequiredResourceFound = true;
                    if (resource.Brightness != -40 ||
                        resource.Contrast != 10 ||
                        resource.LabColor != false ||
                        resource.MeanValueForBrightnessAndContrast != 127)
                    {
                        throw new Exception("BritResource was read wrong");
                    }
                    // Test editing and saving
                    resource.Brightness = 25;
                    resource.Contrast = -14;
                    resource.LabColor = true;
                    resource.MeanValueForBrightnessAndContrast = 200;
                    im.Save(outputPath, new PsdOptions());
                    break;
                }
            }
        }
    }
}

PSDBET-219-将DefaultReplacementFont设置移到ImageOptionsBase类中

// Please, don't intall Konstanting Font, because this test should replace font that is not installed
string sourceFileName = "sample_konstanting.psd";
string[] outputs = new string[]
{
    "replacedfont0.tiff",
    "replacedfont1.png",
    "replacedfont2.jpg"
};
using (PsdImage image = (PsdImage)Image.Load(sourceFileName, new PsdLoadOptions()))
{
    // This way you can use different fonts for different outputs 
    image.Save(outputs[0], new TiffOptions(TiffExpectedFormat.TiffJpegRgb) { DefaultReplacementFont = "Arial" });
    image.Save(outputs[1], new PngOptions { DefaultReplacementFont = "Verdana" });
    image.Save(outputs[2], new JpegOptions { DefaultReplacementFont = "Times New Roman" });
}

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

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


为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP