Registry / ai-ml / blendmodes

blendmodes

JSON →
library2025pypypiunverified

BlendModes is a Python library that allows you to apply various blending modes to a background and foreground image, similar to those found in image editing software. It currently supports version 2025 and releases new major versions annually, with minor patches as needed, typically in January/February.

pip install blendmodes
INSTALL
IMPORT
SIG · BLENDMODES
B
blendmodes
ai-mlpythonv2025
Install
4.3s avg
Import
Disk
110MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2025 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 110.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.3s · import 0.000s · 107MB
110MB installed
● package 110MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

blendLayers
from blendmodes import blendLayers
from blendmodes import blendLayers

This quickstart demonstrates how to create two Pillow images, then blend them together using a specified `BlendType` and opacity, with an optional offset. The result is a new `PIL.Image.Image` object.

from PIL import Image from blendmodes import blendLayers, BlendType # Create dummy images for demonstration. In a real application, # load images from files and ensure they are in 'RGBA' mode. background_img = Image.new("RGBA", (400, 300), (255, 0, 0, 255)) # Red background foreground_img = Image.new("RGBA", (200, 150), (0, 0, 255, 128)) # Semi-transparent blue foreground # Example: Place foreground at offset (50, 50) on background # The blendLayers function handles positioning by drawing the foreground # onto a canvas, then applying the blend mode. # For simpler examples, ensure foreground is smaller or equal to background # or use offsets carefully. # Blend the images using 'multiply' mode with 75% opacity and an offset blended_img = blendLayers( background=background_img, foreground=foreground_img, blendType=BlendType.MULTIPLY, opacity=0.75, offsets=(50, 50) ) # Display or save the result # blended_img.save("blended_image.png") print(f"Blended image created with size: {blended_img.size} and mode: {blended_img.mode}") # blended_img.show() # Uncomment to display the image graphically
Debug
Known issues
breakingThe `imagetools.renderWAlphaOffset` function was removed in version 2024.1. Its functionality for handling image offsets is now integrated directly into the `blendLayers` function via the `offsets` parameter.
fix
Migrate usage to `blendLayers(..., offsets=(x, y))`. Review the `blendLayers` signature for new parameters.
affects: >=2024.1
gotchaWhen using `blendLayers`, if the `background` image is smaller than the `foreground` image, portions of the `foreground` image that extend beyond the `background` dimensions will be cut off.
fix
Ensure your `background` image is sufficiently large to accommodate the `foreground` image at the desired `offsets`, or pre-process/crop the `foreground` image.
affects: >=2024.1
gotchaFor consistent and expected blending results, both `background` and `foreground` images passed to `blendLayers` should be in 'RGBA' mode. Other modes might lead to unexpected color transformations or errors.
fix
Always convert your `PIL.Image.Image` objects to 'RGBA' mode before blending, e.g., `image.convert('RGBA')`.
affects: all
Upgrade
Version history
2025latest on PyPI · released Feb 20, 2025
Audit
Dependencies
PillowrequiredRequired for image manipulation and representation (PIL.Image.Image objects).
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
blendmodes — pip install blendmodes · libregistry