Aspose.PSD for .NET 22.7 - 发行说明
Contents
[
Hide
]
本页包含 Aspose.PSD for .NET 22.7 的发行说明
关键 | 摘要 | 类别 |
---|---|---|
PSDNET-482 | 支持图像部分资源 #4000-4999 插件资源 | 特性 |
PSDNET-875 | Aspose.PSD.dll 中出现未处理的“System.OutOfMemoryException”类型异常 | 错误 |
PSDNET-1050 | 导出 PSD 文件后,结果比源文件大得多 | 错误 |
PSDNET-1083 | 对 XmpResource 的数据解析不正确 | 错误 |
PSDNET-1205 | 导出后,带有子文件夹的 PSD 文件大小增加 | 错误 |
公共 API 更改
已添加的 API:
- T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure.Key
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure.Length
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure.Items
- M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure.SaveData(Aspose.PSD.StreamContainer)
- F:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.AnimatedDataSectionStructure.StructureKey
- T:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource
- P:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource.DataSize
- P:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource.MinimalVersion
- P:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource.KeyName
- P:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource.AnimatedDataSection
- M:Aspose.PSD.FileFormats.Psd.Resources.AnimatedDataSectionResource.SaveData(Aspose.PSD.StreamContainer)
已移除的 API:
- 无
Usage examples:
PSDNET-482. 支持图像部分资源 #4000-4999 插件资源
// 以下代码演示了如何在动画数据的时间轴帧中设置/更新延迟时间。
string sourceFile = "3_animated.psd";
string outputPsd = "output_3_animated.psd";
T FindStructure<T>(IEnumerable<OSTypeStructure> structures, string keyName) where T : OSTypeStructure
{
foreach (var structure in structures)
{
if (structure.KeyName.ClassName == keyName)
{
return structure as T;
}
}
return null;
}
OSTypeStructure[] AddOrReplaceStructure(IEnumerable<OSTypeStructure> structures, OSTypeStructure newStructure)
{
List<OSTypeStructure> listOfStructures = new List<OSTypeStructure>(structures);
for (int i = 0; i < listOfStructures.Count; i++)
{
OSTypeStructure structure = listOfStructures[i];
if (structure.KeyName.ClassName == newStructure.KeyName.ClassName)
{
listOfStructures.RemoveAt(i);
break;
}
}
listOfStructures.Add(newStructure);
return listOfStructures.ToArray();
}
using (PsdImage image = (PsdImage)Image.Load(sourceFile))
{
foreach (var imageResource in image.ImageResources)
{
if (imageResource is AnimatedDataSectionResource)
{
var animatedData =
(AnimatedDataSectionStructure) (imageResource as AnimatedDataSectionResource).AnimatedDataSection;
var framesList = FindStructure<ListStructure>(animatedData.Items, "FrIn");
var frame1 = (DescriptorStructure)framesList.Types[1];
// 创建延迟时间记录,值为 100 个厘秒,相当于 1 秒。
var frameDelay = new IntegerStructure(new ClassID("FrDl"));
frameDelay.Value = 100; // 以厘秒为单位设置时间。
frame1.Structures = AddOrReplaceStructure(frame1.Structures, frameDelay);
break;
}
}
image.Save(outputPsd);
}
PSDNET-875. Aspose.PSD.dll 中出现未处理的“System.OutOfMemoryException”类型异常
string srcFile = "001-.psd";
string jpgFilePath = "T_0003.jpg";
string outputFilePath = "output_newPsd.psd";
using (var im = (PsdImage)Image.Load(srcFile))
{
using (FileStream fs = new FileStream(jpgFilePath, FileMode.Open))
{
var newLayer = new Aspose.PSD.FileFormats.Psd.Layers.Layer(fs);
newLayer.DisplayName = "NewLayer";
im.AddLayer(newLayer);
im.Save(outputFilePath, true);
}
}
PSDNET-1050. 导出 PSD 文件后,结果比源文件大得多
string src = "ShimadzuLetterhead100.psd";
string output = "output.psd";
using (var img = (PsdImage)Image.Load(src))
{
img.Save(output);
}
double outputSizeMb = new FileInfo(output).Length / 1024d / 1024d;
if (outputSizeMb > 6)
{
throw new Exception("输出文件比预期更大。");
}
PSDNET-1083. 对 XmpResource 的数据解析不正确
string inputPsdImagePath = @"input.psd";
string savedPsdImagePath = @"saved.psd";
bool isOriginalContain = false;
bool isSavedContain = false;
// 在输入文件中查找子 XMP 键
using (PsdImage img = (PsdImage)Image.Load(inputPsdImagePath))
{
foreach (var package in img.XmpData.Packages)
{
foreach (var pack in package)
{
if (pack.Value is XmpArray)
{
XmpArray xmpArray = (XmpArray)pack.Value;
string xmlValue = xmpArray.GetXmlValue();
if (xmlValue.Contains("<photoshop:LayerName>test1</photoshop:LayerName>"))
{
isOriginalContain = true;
break;
}
}
}
if (isOriginalContain)
{
break;
}
}
img.Save(savedPsdImagePath);
}
// 在保存的文件中查找子 XMP 键
using (PsdImage img = (PsdImage)Image.Load(savedPsdImagePath))
{
foreach (var package in img.XmpData.Packages)
{
foreach (var pack in package)
{
if (pack.Value is XmpArray)
{
XmpArray xmpArray = (XmpArray)pack.Value;
string xmlValue = xmpArray.GetXmlValue();
if (xmlValue.Contains("<photoshop:LayerName>test1</photoshop:LayerName>"))
{
isSavedContain = true;
break;
}
}
}
if (isSavedContain)
{
break;
}
}
img.Save(savedPsdImagePath);
}
if (isOriginalContain && isSavedContain)
{
// 一切正常!
}
else
{
throw new Exception("无法正常工作");
}
PSDNET-1205. 导出后,带有子文件夹的 PSD 文件大小增加
string[] sourceFiles = new string[] { "1lvlFoldersTest.psd", "5lvlFoldersTest.psd"};
foreach (var fileName in sourceFiles)
{
string sourceFilePath = fileName;
string outputFilePath = "output_" + fileName;
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath))
{
image.Save(outputFilePath);
}
double outputSizeMb = new FileInfo(outputFilePath).Length / 1024d / 1024d;
if (outputSizeMb > 1.9)
{
throw new Exception("输出文件比预期更大。");
}
}