Hi, I want to set the color of a layer reactangule as the following picture, but the color does not change
Captura de pantalla 2023-06-01 115918.png (106.5 KB)
Code:
PsdImage image = (PsdImage)Aspose.PSD.Image.Load(“c:\PSDfile”);
if (layerItem.GetType() != typeof(Layer)) continue;
if(layerItem.DisplayName.Contains("bgcolor")){
layerItem.ReplaceNonTransparentColors(Aspose.PSD.Color.Black);
}
image.Save(opt.Output, new PngOptions() );
}
if(layerItem.DisplayName.Contains("Rectangle 1")){
layerItem.ReplaceColor(Color.White, 40, Color.Orange);
}
PSD:
PSDFileV2.zip (270 Bytes)
@cristianortegaethofy
Please try this code.
foreach (var layerItem in image.Layers)
{
if (layerItem.DisplayName.Contains("bgcolor"))
{
layerItem.ReplaceNonTransparentColors(Aspose.PSD.Color.Orange);
}
if (layerItem.DisplayName.Contains("Rectangle 1"))
{
layerItem.ReplaceColor(Color.Green, 100, Color.Red);
}
}
If you’ll try to save it to the PSD it will not work (but for PNG from your example it’s ok). This will work only with the Regular Raster Layer, because you try to apply this to the ShapeLayer. Unfortunately, Aspose.PSD doesn’t support them, but luckily we’ve added support of this Layers in 23.5, but this class is not public. So, in the release 23.6 we planned to add them to public and for ShapeLayers will be available Stroke and Fill API with the ability to change color similar way to FillLayer