Did you ever modify multilayered PSD files programmatically? We are going to go through a developer-friendly SDK that simplifies working with Photoshop layers in Python programmatically. Yes, we are talking about Aspose.PSD for Python via .NET. This SDK offers enterprise-level features to manipulate PSD files and convert them to other popular file formats. In this guide, we will show you how to add shadows and apply blend modes in PSD files using this Python SDK. So, stick to this blog post till the end and make sure you have set up Python on your machine.

Aspose.PSD for Python via .NET - Installation

You can install Aspose.PSD for Python via .NET by clicking this link. Or you may opt for running the following command:

pip install aspose-psd

Modify PSD Layers: Change Opacity, Blending Modes, Add Drop Shadows, and Color Overlays Programmatically

Let’s go straight to the steps first.

  • Load the PSD file using the PsdImage.load method.
  • Create an object of the PngOptions class to set PNG save options to include alpha (transparency).
  • Save the original, unmodified PSD as a PNG.
  • Set the opacity of the 2nd layer (index 1) to 100%.
  • Set the blending mode of the 5th layer (index 4) to “Hue”.
  • Add a drop shadow effect to the 8th layer (index 7).
  • Change the blending mode of the 10th layer (index 9) to “Lighten”.
  • Add a color overlay effect to the 6th layer (index 5).
  • Save the modified image as a PNG.

The following code sample demonstrates working with Photoshop layers in Python: Output:

psd-layers

Get a Free License

Get a free temporary license to try this SDK beyond evaluation limitations.

Have questions?

Ask your questions on our forum.

Summing up

We are ending this blog post here. This blog post covered working with Photoshop layers in Python programmatically. We went through how to add drop shadows, color overlays, and change opacity. You may try the features yourself, as it is super easy to install Aspose.PSD for Python via .NET. Moreover, it comes with a comprehensive documentation that you may visit here. Further, you may navigate API References and GitHub Examples to learn more.

Explore