Aspose.PSD是高级PSD和入门级AI文件格式操作API,允许创建和编辑Photoshop文件,并提供更新图层属性,添加水印,执行图形操作或将一种文件格式转换为另一种文件的功能,没有任何Adobe Photoshop或Adobe Illustrator依赖项。
Aspose.PSD for .Net更新至新版本v20.12,支持将图层转换为智能对象层,尝试使用SmartObjectLayers打开PSB文件时的未知资源标头,修复图像渲染不正确等问题。
>>你可以点击这里下载Aspose.PSD for .NET v20.12测试体验。
具体更新内容
key |
概述 |
类别 |
PSDNET-757 |
支持将图层转换为智能对象层 |
新功能 |
PSDNET-764 |
如果我们尝试添加PSB文件,则SmartObjectLayer.ReplaceContents方法将引发NullReferenceException |
Bug修复 |
PSDNET-773 |
如果图层大于Canvas,则CMYK 8位和CMYK 16位图像的渲染不正确 |
Bug修复 |
PSDNET-782 |
可以使用我们的API打开保存的PSB文件,但不能使用Photoshop打开 |
Bug修复 |
PSDNET-783 |
如果我们尝试在具有共享数据源的特定PSD中更改智能层,则会出现异常 |
Bug修复 |
PSDNET-765 |
PsdImageException:尝试使用SmartObjectLayers打开PSB文件时的未知资源标头 |
增强功能 |
新功能解析
PSDNET-757——支持将图层转换为智能对象层
string dataDir = "PSDNET757_1\\";
string outputDir = dataDir + "output\\";
// These examples demonstrate how to convert layers to a smart object layer in the PSD file
ExampleOfConvertingToSmartObjectLayer("ThreeRegularLayers", 0, 1);
ExampleOfConvertingToSmartObjectLayer("FourWithMasks", 0, 2);
ExampleOfConvertingToSmartObjectLayer("dummy", 2, 3, 1);
ExampleOfConvertingToSmartObjectLayer("dummy_group", 6, 2);
ExampleOfConvertingToSmartObjectLayer("argb16bit_5x5", 0);
ExampleOfConvertingToSmartObjectLayer("cmyk16bit_5x5", 0);
ExampleOfConvertingToSmartObjectLayer("grayscale5x5", 0);
void ExampleOfConvertingToSmartObjectLayer(string filePath, params int[] layerNumbers)
{
string outputFilePath = outputDir + "Converted_" + filePath + ".psd";
string pngOutputPath = Path.ChangeExtension(outputFilePath, ".png");
using (PsdImage image = (PsdImage)Image.Load(dataDir + filePath + ".psd"))
{
var layerCount = image.Layers.Length;
var smartObjectLayer = image.SmartObjectProvider.ConvertToSmartObject(layerNumbers);
var newLayerCount = image.Layers.Length;
image.Save(pngOutputPath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
image.Save(outputFilePath, new PsdOptions(image));
}
}
PSDNET-765——PsdImageException:尝试使用SmartObjectLayers打开PSB文件时的未知资源标头
// This example demonstrates that the specified PSD file is loaded, saved, and loaded again correctly.
// Test manually that the saved files can be opened by Adobe® Photoshop®
string baseFolder = "PSDNET765_1\\";
string outputFolder = baseFolder + "output\\";
string fileName = "CommonPsb.psb";
string filePath = baseFolder + fileName;
string psbOutputPath = outputFolder + fileName + "_saved.psb";
string psdOutputPath = outputFolder + fileName + "_saved_as_psd.psd";
using (PsdImage image = (PsdImage)Image.Load(filePath))
{
image.Save(psbOutputPath, new PsdOptions(image) { FileFormatVersion = FileFormatVersion.Psb, Resources = null, XmpData = null });
image.Save(psdOutputPath, new PsdOptions(image) { FileFormatVersion = FileFormatVersion.Psd, Resources = null, XmpData = null });
}
using (PsdImage image1 = (PsdImage)Image.Load(psdOutputPath))
{
Console.WriteLine("PSD loaded");
}
using (PsdImage image2 = (PsdImage)Image.Load(psbOutputPath))
{
Console.WriteLine("PSB loaded");
}
如果您有任何疑问或需求,请随时加入Aspose技术交流群(761297826),我们很高兴为您提供查询和咨询。