In My Project,I use Aspose.PSD to parse my psd file.And I find a BUG.That is when I use Layer.BlendingOptions.Effects .That array always empty!!! And after I use AddColorOverlay function and save the psd file,it’s useful but can’t be changed in my PhotoShop application.
language: .NET
PhotoShop Version: PhotoShop CC 2014
dll version: Aspose.PSD.20.5(dlls_only) net4.0
IDEA: Visual Studio 2017
psd download URL : MyPsdFile.zip (43.8 KB)
my code:
private void LoadLicense()
{
//it’s winform
string path = Path.Combine(Application.StartupPath, “License.txt”);
using (FileStream fs = new FileStream(path,FileMode.Open))
{
Aspose.PSD.License l = new Aspose.PSD.License();
l.SetLicense(fs);
}
}
private void GetPSDInfo()
{
string psdPath = Path.Combine(Application.StartupPath, “MyPsdFile.psd”);
using (PsdImage image = (PsdImage)Aspose.PSD.Image.Load(psdPath))
{
Layer[] layers = image.Layers;
StringBuilder sb = new StringBuilder();
foreach (var layer in layers)
{
sb.AppendLine(ParseLayerInfo(layer));
}
ShowText(sb.ToString());
image.Save();
}
}
string ParseLayerInfo(Layer layer)
{
StringBuilder s = new StringBuilder();
s.AppendLine(string.Format("==========={0}:{1}===========", layer.GetType().Name, layer.DisplayName));
//only Open this code can be Effects.Length > 0
//and the effect can’t changed on the PhotoShop
/*
var a = layer.BlendingOptions.AddColorOverlay();
a.Color = Aspose.PSD.Color.Red;
a.IsVisible = true;
a.Opacity = 255;
*/
int len = layer.BlendingOptions.Effects.Length;//this effect length always Zero
s.AppendLine(“Effects Count : " + len);
for (int i = 0; i < len; i++)
{
var effect1 = layer.BlendingOptions.Effects[i];
s.AppendLine(string.Format(”===========effect{0}===========", i));
var effectType = effect1.GetType();
var pps = effectType.GetProperties();
for (int j = 0; j < pps.Length; j++)
{
var pp = pps[j];
object o = pp.GetValue(effect1);
s.AppendLine(string.Format("{0}:{1}", pp.Name, o != null ? o.ToString() : “null”));
}
}
return s.ToString();
}
If fixed this BUG,Send me an email ! Thanks !
my email : linzhenyu_2006@126.com