How to Change color in non-TextLayer in PSD file


#1

Hi,


I have PSD file with multiple layer. There are few non-Text layer, i like to change the color of those non-TextLayer. How can i achieve this functionality

Example: Attached PSD file contain non-textlayer which is named as “Maincolor”, i like to change the color of that layer from light green to Yellow.

what is the method to change color? any alternate method to update this layer with different color?

Code:

using (PsdImage image = (PsdImage)Image.Load(@“PSDFile/photooverlay_5_02.psd”))
{

PsdImage psdImage = image;
var pngOptions = new PngOptions();
foreach (var layer in psdImage.Layers)
{
if (layer.GetType() == typeof(Aspose.Imaging.FileFormats.Psd.Layers.TextLayer))
{
if (layer.Name == “dealerwebsite”)
{
((Aspose.Imaging.FileFormats.Psd.Layers.TextLayer)layer).UpdateText(“My new Text!”, Color.Red);
}
}
else if (layer.Name == “Maincolor”)
{
//layer.BackgroundColor = Color.Yellow;
//TODO: Change color of this layer
}

}
psdImage.Save(@“c:\temp\asposeImage01.png”, new Aspose.Imaging.ImageOptions.PngOptions());
}

#2

Hi Sarvan,

I have observed the PSD file and requirements. I have been able to observe an issue while changing the background color for selected layer. An issue with ID IMAGINGNET-2375 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

We are sorry for your inconvenience,


#3

The issues you have found earlier (filed as IMAGINGNET-2375) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Aspose.


#4

@saravanakumar3856a4e,

I suggest you to please try using following sample code:

string fileName = "photooverlay_5_new";
PngOptions pngOptions = new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha };
using (PsdImage input = (PsdImage)Image.Load(fileName + ".psd"))
{
    foreach (Layer layer in input.Layers)
    {
        if (layer.Name == "Maincolor")
        {
            layer.ReplaceNonTransparentColors(Color.Orange);
            input.Save(fileName + "_nonTransparentColors_result.png", pngOptions);
            input.Save(fileName + "_nonTransparentColors_result.psd");
            break;
        }
    }
}

using (PsdImage input = (PsdImage)Image.Load(fileName + ".psd"))
{
    foreach (Layer layer in input.Layers)
    {
        if (layer.Name == "Maincolor")
        {
            layer.ReplaceColor(Color.LightGreen, 40, Color.Orange);
            input.Save(fileName + "_specificColor_result.png", pngOptions);
            input.Save(fileName + "_specificColor_result.psd");
            break;
        }
    }
}

#5

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.