Psd Blending Options Manipulation

Contents
[ ]

Overview

In Aspose.PSD for Python, you can manipulate blending options to modify the appearance of the layers in your PSD image. The code you provided demonstrates a few examples of how you can use blending options.

First, the code loads a PSD image and saves it as an original PNG file. Then, it modifies the opacity and blending mode of specific layers. For example, it sets the opacity of the second layer to 100 and changes the blending mode of the fifth layer to Hue.

Additionally, the code adds blending effects to certain layers. It uses the add_drop_shadow() method to add a drop shadow effect to the seventh layer. The shadow angle is set to 30 degrees, and the shadow color is set to RGB(255, 0, 0).

Furthermore, the code changes the blending mode of the ninth layer to Lighten. It also adds a color overlay effect to the fifth layer using the add_color_overlay() method. The color overlay color is set to RGB(30, 50, 0), and the opacity is set to 150.

Finally, the code saves the modified image as an updated PNG file.

Overall, Aspose.PSD for Python provides a wide range of blending options that you can use to manipulate the appearance of layers in your PSD images. These options include modifying opacity, changing blending modes, and adding various blending effects like drop shadow and color overlay.

Example

from aspose.psd import Image, Color
from aspose.psd.fileformats.core.blending import BlendMode
from aspose.psd.imageoptions import PsdOptions, PngOptions
from aspose.pycore import cast, is_assignable
from aspose.psd.fileformats.png import PngColorType
source = "AllTypesLayerPsd2.psd"
output_original = "original.png"
output_updated = "output_updated.png"
with PsdImage.load(source) as image:
psdImage = cast(PsdImage, image)
pngSaveOpt = PngOptions()
pngSaveOpt.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
image.save(output_original, pngSaveOpt)
# Change opacity and/or blending mode of layer
psdImage.layers[1].opacity = 100
psdImage.layers[4].blend_mode_key = BlendMode.HUE
# Add effects like shadow and color overlay and set it up
shadow = psdImage.layers[7].blending_options.add_drop_shadow()
shadow.angle = 30
shadow.color = Color.from_argb(255, 255, 0)
psdImage.layers[9].blend_mode_key = BlendMode.LIGHTEN
colorOverlay = psdImage.layers[5].blending_options.add_color_overlay()
colorOverlay.color = Color.from_argb(200, 30, 50)
colorOverlay.opacity = 150
image.save(output_updated, pngSaveOpt)