Aspose.PSD for .NET 20.7 - Release Notes
Contents
[
Hide
]
This page contains release notes for Aspose.PSD for .NET 20.7
Key | Summary | Category |
---|---|---|
PSDNET-673 | Support of LnkE Resource | Feature |
PSDNET-392 | Support of britResource (Resource of Brightness/Contrast Adjustment Layer) | Feature |
PSDNET-629 | Change Exception Message on trying to open not supported formats as an image | Enhancement |
PSDNET-594 | Failed to save LayerMask | Bug |
PSDNET-597 | If we save PSD file after the creation of new Layer Group we get Photoshop warning on the file opening | Bug |
PSDNET-618 | Clipping mask not applying to the folder | Bug |
PSDNET-625 | Cannot open file with Aspose.PSD for .NET | Bug |
PSDNET-650 | Image saving failed exception when converting PSD to PDF | Bug |
PSDNET-655 | rop operation makes Clipping path invalid in PSD image | Bug |
PSDNET-662 | NullReference Exception when trying to save Specific PSD file with the Shadow Effect | Bug |
PSDNET-666 | Aspose.PSD returns true on Image.CanLoad(pdfStream) | Bug |
PSDNET-676 | Layers failed to render in generated PNG | Bug |
PSDNET-677 | Exception on accessing TextData | Bug |
PSDNET-679 | ImageSaveException on saving the PSD | Bug |
Public API Changes
Added APIs:
- M:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.BlendingOptions.AddStroke(Aspose.PSD.FileFormats.Psd.Layers.FillSettings.FillType)
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokeEffect.Overprint
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokeEffect.Position
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokeEffect.Size
- T:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokePosition
- F:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokePosition.Inside
- F:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokePosition.Center
- F:Aspose.PSD.FileFormats.Psd.Layers.LayerEffects.StrokePosition.Outside
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.LiFdDataSource.Data
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk2Resource.Item(System.Int32)
- M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk2Resource.#ctor
- T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk3Resource
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk3Resource.Key
- F:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk3Resource.TypeToolKey
- M:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.Lnk3Resource.#ctor
- T:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource
- M:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.#ctor(System.Byte[])
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.DataSize
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.MinimalVersion
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.Paths
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.Version
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.IsDisabled
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.IsNotLinked
- P:Aspose.PSD.FileFormats.Psd.Resources.WorkingPathResource.IsInverted
- T:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData.Paths
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData.Version
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData.IsDisabled
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData.IsNotLinked
- P:Aspose.PSD.FileFormats.Psd.Layers.LayerResources.VectorPaths.IVectorPathData.IsInverted
Removed APIs:
- M:Aspose.PSD.FileFormats.Psd.PsdImage.AddExposureLayer(System.Single,System.Single,System.Single)
Usage examples:
PSDNET-606. Support of LnkE Resource
void AssertAreEqual(object expected, object actual)
{
if (!object.Equals(actual, expected))
{
throw new FormatException(string.Format("Actual value {0} are not equal to expected {1}.", actual, expected));
}
}
object[] Lnk2ResourceSupportCases = new object[]
{
new object[]
{
"00af34a0-a90b-674d-a821-73ee508c5479",
"rgb8_2x2.png",
"png",
string.Empty,
0x53,
0d,
string.Empty,
7,
true,
0x124L,
0x74cL
}
};
object[] LayeredLnk2ResourceSupportCases = new object[]
{
new object[]
{
"69ac1c0d-1b74-fd49-9c7e-34a7aa6299ef",
"huset.jpg",
"JPEG",
string.Empty,
0x9d46,
0d,
"xmp.did:0F94B342065B11E395B1FD506DED6B07",
7,
true,
0x9E60L,
0xc60cL
},
new object[]
{
"5a7d1965-0eae-b24e-a82f-98c7646424c2",
"panama-papers.jpg",
"JPEG",
string.Empty,
0xF56B,
0d,
"xmp.did:BDE940CBF51B11E59D759CDA690663E3",
7,
true,
0xF694L,
0x10dd4L
},
};
object[] LayeredLnk3ResourceSupportCases = new object[]
{
new object[]
{
"2fd7ba52-0221-de4c-bdc4-1210580c6caa",
"panama-papers.jpg",
"JPEG",
string.Empty,
0xF56B,
0d,
"xmp.did:BDE940CBF51B11E59D759CDA690663E3",
7,
true,
0xF694l,
0x10dd4L
},
new object[]
{
"372d52eb-5825-8743-81a7-b6f32d51323d",
"huset.jpg",
"JPEG",
string.Empty,
0x9d46,
0d,
"xmp.did:0F94B342065B11E395B1FD506DED6B07",
7,
true,
0x9E60L,
0xc60cL
},
};
var basePath = @"PSDNET392_1\";
const string Output = "Output\\";
// Saves the data of a smart object in PSD file to a file.
void SaveSmartObjectData(string prefix, string fileName, byte[] data)
{
var filePath = basePath + prefix + "_" + fileName;
using (var container = FileStreamContainer.CreateFileStream(filePath, false))
{
container.Write(data);
}
}
// Loads the new data for a smart object in PSD file.
byte[] LoadNewData(string fileName)
{
using (var container = FileStreamContainer.OpenFileStream(basePath + fileName))
{
return container.ToBytes();
}
}
// Gets and sets properties of the PSD Lnk2 / Lnk3 Resource and its liFD data sources in PSD image
void ExampleOfLnk2ResourceSupport(
string fileName,
int dataSourceCount,
int length,
int newLength,
object[] dataSourceExpectedValues)
{
using (PsdImage image = (PsdImage)Image.Load(basePath + fileName))
{
Lnk2Resource lnk2Resource = null;
foreach (var resource in image.GlobalLayerResources)
{
lnk2Resource = resource as Lnk2Resource;
if (lnk2Resource != null)
{
AssertAreEqual(lnk2Resource.DataSourceCount, dataSourceCount);
AssertAreEqual(lnk2Resource.Length, length);
AssertAreEqual(lnk2Resource.IsEmpty, false);
for (int i = 0; i < lnk2Resource.DataSourceCount; i++)
{
LiFdDataSource lifdSource = lnk2Resource[i];
object[] expected = (object[])dataSourceExpectedValues[i];
AssertAreEqual(LinkDataSourceType.liFD, lifdSource.Type);
AssertAreEqual(new Guid((string)expected[0]), lifdSource.UniqueId);
AssertAreEqual(expected[1], lifdSource.OriginalFileName);
AssertAreEqual(expected[2], lifdSource.FileType.TrimEnd(' '));
AssertAreEqual(expected[3], lifdSource.FileCreator.TrimEnd(' '));
AssertAreEqual(expected[4], lifdSource.Data.Length);
AssertAreEqual(expected[5], lifdSource.AssetModTime);
AssertAreEqual(expected[6], lifdSource.ChildDocId);
AssertAreEqual(expected[7], lifdSource.Version);
AssertAreEqual((bool)expected[8], lifdSource.HasFileOpenDescriptor);
AssertAreEqual(expected[9], lifdSource.Length);
if (lifdSource.HasFileOpenDescriptor)
{
AssertAreEqual(-1, lifdSource.CompId);
AssertAreEqual(-1, lifdSource.OriginalCompId);
lifdSource.CompId = int.MaxValue;
}
SaveSmartObjectData(
Output + fileName,
lifdSource.OriginalFileName,
lifdSource.Data);
lifdSource.Data = LoadNewData("new_" + lifdSource.OriginalFileName);
AssertAreEqual(expected[10], lifdSource.Length);
lifdSource.ChildDocId = Guid.NewGuid().ToString();
lifdSource.AssetModTime = double.MaxValue;
lifdSource.FileType = "test";
lifdSource.FileCreator = "me";
}
AssertAreEqual(newLength, lnk2Resource.Length);
break;
}
}
AssertAreEqual(true, lnk2Resource != null);
if (image.BitsPerChannel < 32) // 32 bit per channel saving is not supported yet
{
image.Save(basePath + Output + fileName, new PsdOptions(image));
}
}
}
// This example demonstrates how to get and set properties of the PSD Lnk2 Resource and its liFD data sources for 8 bit per channel.
ExampleOfLnk2ResourceSupport("rgb8_2x2_embedded_png.psd", 1, 0x12C, 0x0000079c, Lnk2ResourceSupportCases);
// This example demonstrates how to get and set properties of the PSD Lnk3 Resource and its liFD data sources for 32 bit per channel.
ExampleOfLnk2ResourceSupport("Layered PSD file smart objects.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk3ResourceSupportCases);
// This example demonstrates how to get and set properties of the PSD Lnk2 Resource and its liFD data sources for 16 bit per channel.
ExampleOfLnk2ResourceSupport("LayeredSmartObjects16bit.psd", 2, 0x19504, 0x0001d3e0, LayeredLnk2ResourceSupportCases);
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
});
}
/* 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;
}
}
}
}
}
string sourceFilePath = "MaskTestNormalBlendMaskOnGroup.psd";
string outputFilePath = "MaskTestNormalBlendMaskOnGroup.png";
using (var input = (PsdImage)Image.Load(sourceFilePath))
{
input.Save(outputFilePath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
PSDNET-610. NullReference Exception when trying to convert particular Psd file to image
using (var psdImage = (PsdImage)Image.Load("Certificate.psd"))
{
psdImage.Save("output.png", new PngOptions());
}
PSDNET-636. Resizing PSD files works incorrectly if there is a mask in the adjustment layer that has empty bounds
int scale = 2;
string[] names = {
"OneRegularAndOneAdjustmentWithVectorAndLayerMask",
"LevelsLayerWithLayerMaskRgb",
"LevelsLayerWithLayerMaskCmyk",
};
for (int i = 0; i < names.Length; i++)
{
string sourceFilePath = names[i] + ".psd";
string outputFilePath = "output_" + sourceFilePath;
string outputPngFilePath = "output_" + names[i] + ".png";
var psdLoadOptions = new PsdLoadOptions() { LoadEffectsResource = true };
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath, psdLoadOptions))
{
image.Resize(image.Width * scale, image.Height * scale);
image.Save(outputFilePath, new PsdOptions());
image.Save(outputPngFilePath, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
}
PSDNET-611. OverflowException when trying to open particular Psd file
using (var psdImage = (PsdImage)Image.Load("CT_SkillTest_v1.psd"))
{
psdImage.Save("output.psd");
}
// Loaded and saved without throwing exceptions.
PSDNET-565. Psd Image with RGB mode 16 bit/channel updates layers only on preview
string sourceFilePath = @"in.psd";
string outputFilePath = @"output.psd";
PsdLoadOptions options = new PsdLoadOptions();
using (PsdImage image = (PsdImage)Image.Load(sourceFilePath, options))
{
foreach (var layer in image.Layers)
{
if (!(layer is LayerGroup) && !(layer is AdjustmentLayer) && (layer.Width > 100) && (layer.Height > 100))
{
Graphics graphics = new Graphics(layer);
graphics.DrawString(layer.Name, new Font("Arial", 10), new SolidBrush(Color.Red), 15, 45);
graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));
}
}
image.Save(outputFilePath, new PsdOptions(image));
}
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);
}
}
object[] ComplexLnkEResourceSupportCases = new object[]
{
new object[]
{
"10fc87d0-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/or hdr btns” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633541.0d,
"uuid:8485ca8d-9496-7f4d-9ef7-4243a00d4161",
"OneReview-InDesign-InContextTranslation",
"or hdr btns.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b4
},
new object[]
{
"10fc87cc-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/cs Id icon” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633512.0d,
"uuid:c18be832-adf7-4b43-8223-a9740807a66c",
"OneReview-InDesign-InContextTranslation",
"cs Id icon.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b0
},
new object[]
{
"10fef79c-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/pointer cursor” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633570.0d,
"uuid:9d7ccaac-f094-214b-8721-1a07ae8700a9",
"OneReview-InDesign-InContextTranslation",
"pointer cursor.ai",
0L,
"",
6,
"unlicensed",
false,
0x03c0
},
new object[]
{
"10fef79a-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/x” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633555.0d,
"uuid:b28aa699-21d6-2d4d-a4c7-790234c1b6ba",
"OneReview-InDesign-InContextTranslation",
"x.ai",
0L,
"",
6,
"unlicensed",
false,
0x38c
},
new object[]
{
"10fef79b-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/modal btns” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633562.0d,
"uuid:1bd42767-058d-da44-bdee-eada3b9d40a5",
"OneReview-InDesign-InContextTranslation",
"modal btns.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b0
},
new object[]
{
"10fc87cd-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/cs ppt icon” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633519.0d,
"uuid:215499ac-ac44-b44d-894b-9ff2c7008d9d",
"OneReview-InDesign-InContextTranslation",
"cs ppt icon.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b4
},
new object[]
{
"10fc87cf-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/cs AI icon” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633534.0d,
"uuid:a67964d4-8682-d649-8118-474cb1776264",
"OneReview-InDesign-InContextTranslation",
"cs AI icon.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b0
},
new object[]
{
"10fc87ce-688f-1179-9685-9d0a040abdc3",
@"CC Libraries Asset “OneReview-InDesign-InContextTranslation/cs PSD icon” (Feature is available in Photoshop CC 2015)",
"01/01/0001 00:00:00",
1463698633527.0d,
"uuid:8e9d5745-9f23-6f49-968e-647a45811bcb",
"OneReview-InDesign-InContextTranslation",
"cs PSD icon.ai",
0L,
"",
6,
"unlicensed",
false,
0x3b4
},
};
void ExampleOfComplexLnkEResourceSupport(string filePath, int length, int length2, object[] dataSourceExpectedValues)
{
filePath = @"PSDNET652_1\" + filePath;
string fileName = Path.GetFileName(filePath);
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.DataSourceCount, 8);
AssertAreEqual(lnkeResource.Length, length);
AssertAreEqual(lnkeResource.IsEmpty, false);
for (int i = 0; i < lnkeResource.DataSourceCount; i++)
{
LiFeDataSource liFeSource = lnkeResource[i];
object[] expected = (object[])dataSourceExpectedValues[i];
AssertAreEqual(liFeSource.Type, LinkDataSourceType.liFE);
AssertAreEqual(liFeSource.UniqueId, new Guid((string)expected[0]));
AssertAreEqual(liFeSource.FullPath, expected[1]);
AssertAreEqual(liFeSource.Date.ToString(CultureInfo.InvariantCulture), expected[2]);
AssertAreEqual(liFeSource.AssetModTime, expected[3]);
AssertAreEqual(liFeSource.ChildDocId, expected[4]);
AssertAreEqual(liFeSource.FileName, expected[5]);
AssertAreEqual(liFeSource.OriginalFileName, expected[6]);
AssertAreEqual(liFeSource.FileSize, expected[7]);
AssertAreEqual(liFeSource.FileType, expected[8]);
AssertAreEqual(liFeSource.FileCreator.TrimEnd(' '), string.Empty);
AssertAreEqual(liFeSource.Version, expected[9]);
AssertAreEqual(liFeSource.AdobeStockLicenseState, expected[10]);
AssertAreEqual(liFeSource.HasFileOpenDescriptor, (bool)expected[11]);
if (liFeSource.HasFileOpenDescriptor)
{
AssertAreEqual(liFeSource.CompId, -1);
AssertAreEqual(liFeSource.OriginalCompId, -1);
liFeSource.CompId = int.MaxValue;
}
liFeSource.FullPath = @"file:///C:/Aspose/net/Aspose.Psd/test/testdata/Images/Psd/SmartObjects/rgb8_2x2.png";
liFeSource.FileName = "rgb8_2x23.png";
liFeSource.ChildDocId = Guid.NewGuid().ToString();
liFeSource.Date = DateTime.Now;
liFeSource.AssetModTime = double.MaxValue;
liFeSource.FileSize = long.MaxValue;
liFeSource.FileType = "test";
liFeSource.FileCreator = "file";
AssertAreEqual(liFeSource.Length, expected[12]);
}
AssertAreEqual(lnkeResource.Length, length2);
break;
}
}
AssertIsTrue(lnkeResource != null);
}
}
ExampleOfComplexLnkEResourceSupport(
"OneReview-InDesign-RefreshPreviewIxD(2).psd",
0x21ac,
0x1db8,
ComplexLnkEResourceSupportCases);
PSDNET-638. Incorrect Layer Order after you add Layer Group to empty Layer Group
using (var createOptions = new PsdOptions())
{
createOptions.Source = new StreamSource(new MemoryStream());
using (var psdImage = (PsdImage)Image.Create(createOptions, 1, 1))
{
LayerGroup group1 = psdImage.AddLayerGroup("Group 1", 0, true);
LayerGroup group2 = group1.AddLayerGroup("Group 2", 0);
if (group1.Layers.Length != 2)
{
throw new Exception("Group 1 must contain two layers of Group 2.");
}
psdImage.Save("output.psd");
}
}
PSDBET-219. Move DefaultReplacementFont setting into ImageOptionsBase class
// 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" });
}