psd file:
https://www.youheyuanpin.com/neiyi.psd
video:
https://www.youheyuanpin.com/neiyi.mp4
psd file:
https://www.youheyuanpin.com/neiyi.psd
video:
https://www.youheyuanpin.com/neiyi.mp4
@mudassir.fayyaz 谢谢您的回复,我是要替换智能对象中的图层,但是我使用
SmartObjectLayer smartObjectLayer = (SmartObjectLayer)layerToReplace;
smartObjectLayer.ReplaceContents(Path.Combine(AppContext.BaseDirectory, replaceImg));
替换智能对象中的图层的时候,保存的psd文件中看起来正常,但是,并没有更新智能图层,您能否使用我发的 psd文件,测试一下?
软件环境为 .net core 3.1
using (PsdImage image = (PsdImage)Image.Load(Path.Combine(AppContext.BaseDirectory, psdFie)))
{
var lic = new Aspose.PSD.License();
lic.SetLicense(Path.Combine(AppContext.BaseDirectory, “Aspose.Total.Product.Family_2.lic”));
PngOptions pngOptions = new PngOptions();
var layerToReplaces = FindLayers(layerName, image);
foreach (var layerToReplace in layerToReplaces)
{
SmartObjectLayer smartObjectLayer = (SmartObjectLayer)layerToReplace;
smartObjectLayer.ReplaceContents(Path.Combine(AppContext.BaseDirectory, replaceImg));
smartObjectLayer.EmbedLinked();
}
//image.SmartObjectProvider.UpdateAllModifiedContent();
image.Save(Path.Combine(AppContext.BaseDirectory, "test1.psd"), new PsdOptions(image));
您共享的示例代码很好。 您也可以检查以下线程链接。 能否请您共享生成的PSD以及替换后的代码中使用的源图像,以便我进行验证。 还请提供在保存的PSD中未更新的图层快照。
@mudassir.fayyaz
模板psd文件:http://www.youheyuanpin.com/psdtest/neiyi.psd
其中替换智能对象图层的名:sucai
替换的素材:http://www.youheyuanpin.com/psdtest/bg6.png
生成的psd:http://www.youheyuanpin.com/psdtest/test1.psd
生成的jpg:http://www.youheyuanpin.com/psdtest/test1.jpg
生成的png:http://www.youheyuanpin.com/psdtest/test1.png
代码如下:
using (PsdImage image = (PsdImage)Image.Load(Path.Combine(AppContext.BaseDirectory, psdFie)))
{
var lic = new Aspose.PSD.License();
lic.SetLicense(Path.Combine(AppContext.BaseDirectory, “Aspose.Total.Product.Family_2.lic”));
var layerToReplaces = FindLayers(layerName, image);
foreach (var layerToReplace in layerToReplaces)
{
SmartObjectLayer smartObjectLayer = (SmartObjectLayer)layerToReplace;
smartObjectLayer.ReplaceContents(Path.Combine(AppContext.BaseDirectory, replaceImg));
smartObjectLayer.EmbedLinked();
//using (var innerImage = (RasterImage)smartObjectLayer.LoadContents(null))
//{
// using (Stream stream = new FileStream(Path.Combine(AppContext.BaseDirectory, replaceImg), FileMode.Open))
// {
// var newLayer = new Layer(stream);
// // Drawing of new layer on the old
// var graphic = new Graphics(innerImage);
// graphic.Clear(Color.Empty);
// graphic.DrawImage(newLayer, new Rectangle(new Point() { X = x, Y = y }, new Size(1000, 1000)));
// }
// smartObjectLayer.ReplaceContents(innerImage);
// //innerImage.Save(Path.Combine(AppContext.BaseDirectory, "innerImage.psb"));
// //// Let's replace the linked smart object image in the PSD layer
// //smartObjectLayer.ReplaceContents(Path.Combine(AppContext.BaseDirectory, "innerImage.psb"));
//}
}
//image.SmartObjectProvider.UpdateAllModifiedContent();
image.Save(Path.Combine(AppContext.BaseDirectory, "test1.psd"), new PsdOptions(image));
var jpegOptions = new JpegOptions();
jpegOptions.Quality = 50;
image.Save(Path.Combine(AppContext.BaseDirectory, "test1.jpg"), jpegOptions);
PngOptions pngOptions = new PngOptions();
image.Save(Path.Combine(AppContext.BaseDirectory, "test1.png"), pngOptions);
private List FindLayers(string layerName, PsdImage image)
{
List result = new List();
// Get aa layers in PSD file
var layers = image.Layers;
// Find desired layer
foreach (var layer in layers)
{
// Match layer’s name
if (string.Equals(layer.DisplayName, layerName, StringComparison.InvariantCultureIgnoreCase))
{
result.Add(layer);
}
}
return result;
}
@mudassir.fayyaz 谢谢您的回复。但是我希望能得到一个具体的时间节点,因为我们现在正在选择psd的技术服务,在测试这些功能能否满足我们的技术要求,如果这个实现不了的话,我们这边很难做出采购的aspose.psd for net 的决策。
我已要求我们的小组调查此问题,我们将尽快与您联系,并请您耐心等待。
The issues you have found earlier (filed as PSDNET-864) have been fixed in this update. This message was posted using Bugs notification tool by yaroslav.lisovskyi