Skip to content

psd-tools/image-blender

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image-blender

image-blender is a Python extension which provides a fast implementation of Adobe Photoshop's blend modes. It is written using Cython. It was supposed to be a helper module for psd-tools package back in 2015, but ended up in release hell as I've lost an inspiration.

Development status PyPI version

Usage

image-blender is not a complete solution, it only provides you with blend functions themselves, so you can blend two images together. You should use some additional Python package to work with images and alpha-composite them (e.g. Pillow or pymaging).

There are some requirements that should be met to apply a blend function to a pair of images:

  1. Blend functions work with bytes, so you must pass a raw image data into them;
  2. Both images must be in RGBA mode and have the same size;
  3. Both images must have a bit depth of 32 bits (8 bits per channel).

Let's take a look at some use cases, but first let's define one helper function and make some preparations. From now on it's assumed you're using Pillow and all of the above requirements are already met:

The above function applies a constant opacity to an image with existing alpha channel. Now let's go to the examples:

License

Copyright 2015-2023 Evgeny Kopylov. Licensed under the MIT License.