Image effects
Like many image editing tools, we also provide functionalities of "styling" a layer (ImageLayer) of a multi-layer image (ImageMultiLayer).
1. Mix two images by effects
We use image mixing as an example. Both images are sized to (256, 256). The first image (A) has an alpha channel, and a red block is centered. The second image (B) is a JPEG file. During the mixing, the second image will "overlay" the first image, while the alpha channel of the "bottom" layer will be preserved.
img = stet.ImageMultiLayer((256, 256), "png").add_image(
stet.ImageSingle("example-mix-a.png"), "block"
)
img.layers["block"].add_overlay_image(
stet.ImageSingle("example-mix-b.jpg").img, mode="add"
)
Here, the mode is the blending mode of the effect layer. In this example, we use the two most representative modes, arithmetic addition and subtraction, as examples. The final results of mode="add" and mode="subtract" are displayed as follows:
| Image A | Image B | A+B | A-B |
|---|---|---|---|
![]() | ![]() | ![]() |
2. Overview of different blending modes
There are more blending modes when rendering effects. In the following examples, we mix the same images with different blending modes. To make a showcase of all results, we use the tool ImageGrids.
ImageGrids is used for stacking many images with the same space.
res = stet.improc.tools.ImageGrids(
n_cols, # Number of images (columns) in a row.
width=n_cols * 256, # The image width.
margins=(10, 10), # The outer padding of all images.
gaps=(10, 10), # The gap size between images.
bg_color="#888888", # The background color.
)
res.append(img) # Add an image to the grid.
...
res.img # Get the stacked image.
Most blending modes of effects can be viewed as functions requiring two images as arguments. In the following stack, the effects are grouped into three parts. The first part shows an image overlaid with a white light. The light has an "S" symbol at the center. In the second part, we use the same image (containing three blocks), but invert the light to "black". In the third part, we display only the effects, using one image as the argument.
example-composers.jpg
More details can be found in the following script:
The list of available blending modes can be found in ImageComposer. The details of these modes can also be found here:
3. Overview of different effects
We can customize the effects of an image layer by calling its layer API:
img = stet.ImageMultiLayer((256, 256), "png").add_image(...)
img.layers["block"].add_overlay_image(...)
img.layers["block"].set_shadow(...)
img.layers["block"].set_glow(...)
...
The details of the usage can be found in ImageLayer. The following example shows the stack of all representative effects. Note that multiple effects can be configured on the same image layer. These effects are inspired by the "layer style" of some image editing software.
example-effects.jpg
More details can be found in the following script:


