彩票走势图

PSD文件处理API-Aspose.PSD v20.2全新上线!6大新功能邀您一同体验!

原创|产品更新|编辑:李显亮|2020-02-28 13:14:29.577|阅读 247 次

概述:Aspose.PSD for .Net是高级PSD和入门级AI文件格式操作API,允许创建和编辑Photoshop文件,令人兴奋的是,.NET版Aspose.PSD迎来了2月的最新更新!新增了六大新功能,欢迎下载体验。

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

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

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

  • 改进了在“文本层”中呈现不同颜色的文本的能力
  • 支持clbl资源(层资源包含有关Blend裁剪元素的信息)
  • 支持blwh资源(资源包含黑白调整层数据)
  • 能够将图层组导出到Jpeg / Png / Tiff / Gif / Bmp / Jpeg2000 / Psd / Psb / Pdf
  • 支持lspf资源(包含有关“受保护的层”设置的设置)
  • 支持infx资源(包含有关内部元素混合的数据)

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


具体更新内容

key 概述 类别
PSDNET-206 改进了在“文本层”中呈现不同颜色的文本的能力 新功能
PSDNET-369 支持clbl资源(层资源包含有关Blend裁剪元素的信息) 新功能
PSDNET-274 支持blwh资源(资源包含黑白调整层数据) 新功能
PSDNET-230 能够将图层组导出到Jpeg / Png / Tiff / Gif / Bmp / Jpeg2000 / Psd / Psb / Pdf 新功能
PSDNET-372 支持lspf资源(包含有关“受保护的层”设置的设置) 新功能
PSDNET-370 支持infx资源(包含有关内部元素混合的数据) 新功能
PSDNET-251 重构PsdImage和Layer以更改转换行为(如果我们分别转换一层,则正确调整图层蒙版的大小/旋转/裁剪) 增强功能
PSDNET-276 在某些全球化设置中,无法打开AI Image光栅图像 Bug修复

PSDNET-194 在图层上执行FlipRotate操作后,PSD图像变得不可读 Bug修复

PSDNET-177 加载PSD文件时出现System.ArgumentException Bug修复

PSDNET-249 仅对图层使用转换方法后,保存的图层的边界或蒙版不正确 Bug修复

用法示例

PSDNET-206——改进了在“文本层”中呈现不同颜色的文本的能力

using (var psdImage = (PsdImage)Image.Load("text_ethalon_different_colors.psd"))
{
    var txtLayer = (TextLayer)psdImage.Layers[1];
    txtLayer.TextData.UpdateLayerData();
    psdImage.Save("output.png", new PngOptions());
}

PSDNET-369——支持clbl资源(层资源包含有关Blend裁剪元素的信息)

void AssertIsTrue(bool condition, string message)
 {
     if (!condition)
     {
         throw new FormatException(message);
     }
 }
 
 string sourceFileName = "SampleForResource.psd";
 string destinationFileName = "Output" + sourceFileName;
 
 ClblResource GetClblResource(PsdImage im)
 {
     foreach (var layer in im.Layers)
     {
         foreach (var layerResource in layer.Resources)
         {
             if (layerResource is ClblResource)
             {
                 return (ClblResource)layerResource;
             }
         }
     }
 
     throw new Exception("The specified ClblResource not found");
 }
 
 using (PsdImage im = (PsdImage)Image.Load(sourceFileName))
 {
     var resource = GetClblResource(im);
     AssertIsTrue(resource.BlendClippedElements, "The ClblResource.BlendClippedElements should be true");
 
     // Test editing and saving
     resource.BlendClippedElements = false;
     im.Save(destinationFileName);
 }
 
 using (PsdImage im = (PsdImage)Image.Load(destinationFileName))
 {
     var resource = GetClblResource(im);
     AssertIsTrue(!resource.BlendClippedElements, "The ClblResource.BlendClippedElements should change to false");
 }

PSDNET-274——支持blwh资源(资源包含黑白调整层数据)

const string ActualPropertyValueIsWrongMessage = "Expected property value is not equal to actual value";
void AssertIsTrue(bool condition, string message)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}
 
void ExampleSupportOfBlwhResource(
    string sourceFileName,
    int reds,
    int yellows,
    int greens,
    int cyans,
    int blues,
    int magentas,
    bool useTint,
    int bwPresetKind,
    string bwPresetFileName,
    double tintColorRed,
    double tintColorGreen,
    double tintColorBlue,
    int tintColor,
    int newTintColor)
{
    string destinationFileName = "Output" + sourceFileName;
    bool isRequiredResourceFound = false;
    using (PsdImage im = (PsdImage)Image.Load(sourceFileName))
    {
        foreach (var layer in im.Layers)
        {
            foreach (var layerResource in layer.Resources)
            {
                if (layerResource is BlwhResource)
                {
                    var blwhResource = (BlwhResource)layerResource;
                    var blwhLayer = (BlackWhiteAdjustmentLayer)layer;
                    isRequiredResourceFound = true;
 
                    AssertIsTrue(blwhResource.Reds == reds, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.Yellows == yellows, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.Greens == greens, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.Cyans == cyans, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.Blues == blues, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.Magentas == magentas, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.UseTint == useTint, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.TintColor == tintColor, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.BwPresetKind == bwPresetKind, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == bwPresetFileName, ActualPropertyValueIsWrongMessage);
                    AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue) < 1e-6, ActualPropertyValueIsWrongMessage); // Test editing and saving blwhResource.Reds = reds - 15; blwhResource.Yellows = yellows - 15; blwhResource.Greens = greens + 15; blwhResource.Cyans = cyans + 15; blwhResource.Blues = blues - 15; blwhResource.Magentas = magentas - 15; blwhResource.UseTint = !useTint; blwhResource.BwPresetKind = 4; blwhResource.BlackAndWhitePresetFileName = "bwPresetFileName"; blwhLayer.TintColorRed = tintColorRed - 60; blwhLayer.TintColorGreen = tintColorGreen - 60; blwhLayer.TintColorBlue = tintColorBlue - 60; im.Save(destinationFileName); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found"); isRequiredResourceFound = false; using (PsdImage im = (PsdImage)Image.Load(destinationFileName)) { foreach (var layer in im.Layers) { foreach (var layerResource in layer.Resources) { if (layerResource is BlwhResource) { var blwhResource = (BlwhResource)layerResource; var blwhLayer = (BlackWhiteAdjustmentLayer)layer; isRequiredResourceFound = true; AssertIsTrue(blwhResource.Reds == reds - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Yellows == yellows - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Greens == greens + 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Cyans == cyans + 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Blues == blues - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.Magentas == magentas - 15, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.UseTint == !useTint, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.TintColor == newTintColor, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BwPresetKind == 4, ActualPropertyValueIsWrongMessage); AssertIsTrue(blwhResource.BlackAndWhitePresetFileName == "bwPresetFileName", ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorRed - tintColorRed + 60) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorGreen - tintColorGreen + 60) < 1e-6, ActualPropertyValueIsWrongMessage); AssertIsTrue(Math.Abs(blwhLayer.TintColorBlue - tintColorBlue + 60) < 1e-6, ActualPropertyValueIsWrongMessage); break; } } } } AssertIsTrue(isRequiredResourceFound, "The specified BlwhResource not found"); } ExampleSupportOfBlwhResource( "BlackWhiteAdjustmentLayerStripesMask.psd", 0x28, 0x3c, 0x28, 0x3c, 0x14, 0x50, false, 1, "\0", 225.00045776367188, 211.00067138671875, 179.00115966796875, -1977421, -5925001); ExampleSupportOfBlwhResource( "BlackWhiteAdjustmentLayerStripesMask2.psd", 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, true, 4, "\0", 239.996337890625, 127.998046875, 63.9990234375, -1015744, -4963324); Console.WriteLine("BlwhResource updating works as expected. Press any key.");

PSDNET-230——能够将图层组导出到Jpeg / Png / Tiff / Gif / Bmp / Jpeg2000 / Psd / Psb / Pdf

using (var psdImage = (PsdImage)Image.Load("1.psd"))
           {
               // folder with background
               LayerGroup bg_folder = (LayerGroup)psdImage.Layers[0];
               // folder with content
               LayerGroup content_folder = (LayerGroup)psdImage.Layers[4];
 
               bg_folder.Save("background.png", new PngOptions());
               content_folder.Save("content.png", new PngOptions());
           }

PSDNET-372——支持lspf资源(包含有关“受保护的层”设置的设置)

const string ActualPropertyValueIsWrongMessage = "Expected property value is not equal to actual value";
void AssertIsTrue(bool condition, string message)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}
 
string sourceFileName = "SampleForResource.psd";
string destinationFileName = "Output" + sourceFileName;
bool isRequiredResourceFound = false;
using (PsdImage im = (PsdImage)Image.Load(sourceFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is LspfResource)
            {
                var resource = (LspfResource)layerResource;
 
                isRequiredResourceFound = true;
 
                AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage);
 
                // Test editing and saving
                resource.IsCompositeProtected = true;
                AssertIsTrue(true == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage);
 
                resource.IsCompositeProtected = false;
                resource.IsPositionProtected = true;
                AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(true == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage);
 
                resource.IsPositionProtected = false;
                resource.IsTransparencyProtected = true;
                AssertIsTrue(false == resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(false == resource.IsPositionProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(true == resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage);
 
                resource.IsCompositeProtected = true;
                resource.IsPositionProtected = true;
                resource.IsTransparencyProtected = true;
 
                im.Save(destinationFileName);
                break;
            }
        }
    }
}
 
AssertIsTrue(isRequiredResourceFound, "The specified LspfResource not found");
isRequiredResourceFound = false;
 
using (PsdImage im = (PsdImage)Image.Load(destinationFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is LspfResource)
            {
                var resource = (LspfResource)layerResource;
 
                isRequiredResourceFound = true;
 
                AssertIsTrue(resource.IsCompositeProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(resource.IsPositionProtected, ActualPropertyValueIsWrongMessage);
                AssertIsTrue(resource.IsTransparencyProtected, ActualPropertyValueIsWrongMessage);
 
                break;
            }
        }
    }
}
 
AssertIsTrue(isRequiredResourceFound, "The specified LspfResource not found");
Console.WriteLine("LspfResource updating works as expected. Press any key.");

PSDNET-370——支持infx资源(包含有关内部元素混合的数据)

void AssertIsTrue(bool condition, string message)
{
    if (!condition)
    {
        throw new FormatException(message);
    }
}
 
string sourceFileName = "SampleForResource.psd";
string destinationFileName = "Output" + sourceFileName;
bool isRequiredResourceFound = false;
using (PsdImage im = (PsdImage)Image.Load(sourceFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is InfxResource)
            {
                var resource = (InfxResource)layerResource;
                isRequiredResourceFound = true;
                AssertIsTrue(!resource.BlendInteriorElements, "The InfxResource.BlendInteriorElements should be false");
 
                // Test editing and saving
                resource.BlendInteriorElements = true;
                im.Save(destinationFileName);
                break;
            }
        }
    }
}
 
AssertIsTrue(isRequiredResourceFound, "The specified InfxResource not found");
isRequiredResourceFound = false;
 
using (PsdImage im = (PsdImage)Image.Load(destinationFileName))
{
    foreach (var layer in im.Layers)
    {
        foreach (var layerResource in layer.Resources)
        {
            if (layerResource is InfxResource)
            {
                var resource = (InfxResource)layerResource;
                isRequiredResourceFound = true;
                AssertIsTrue(resource.BlendInteriorElements, "The InfxResource.BlendInteriorElements should change to true");
 
                break;
            }
        }
    }
}
 
AssertIsTrue(isRequiredResourceFound, "The specified InfxResource not found");

PSDNET-251——重构PsdImage和Layer以更改转换行为(如果我们分别转换一层,则正确调整图层蒙版的大小/旋转/裁剪)

var enums = (RotateFlipType[])Enum.GetValues(typeof(RotateFlipType));
var fileNames = new string[]
{
    "OneRegularAndOneAdjustmentWithVectorAndLayerMask",
    "OneRegularAndOneAdjustmentWithLayerMask", 
    "TextLayer",
    "LinkedShapesWithText"
};
foreach (string fileName in fileNames)
{
    foreach (RotateFlipType rotateFlipType in enums)
    {
        string sourceFileName = fileName + ".psd";
        string destinationFileName = fileName + "_" + rotateFlipType;
 
        var psdLoadOptions = new PsdLoadOptions() { LoadEffectsResource = true };
        using (PsdImage image = (PsdImage)Image.Load(sourceFileName, psdLoadOptions))
        {
            image.RotateFlip(rotateFlipType);
            image.Save(destinationFileName);
        }
    }
}

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

标签:

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


为你推荐

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


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP