{"id":28400264,"url":"https://github.com/psd-tools/image-blender","last_synced_at":"2025-07-31T02:13:33.280Z","repository":{"id":57437810,"uuid":"350980929","full_name":"psd-tools/image-blender","owner":"psd-tools","description":"Python extension which provides a fast implementation of Adobe Photoshop's blend modes","archived":false,"fork":false,"pushed_at":"2023-08-17T11:17:34.000Z","size":785,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-10T15:14:34.759Z","etag":null,"topics":["blend-modes","blending","chops","composition","imagechops","images","layers","photoshop","python"],"latest_commit_sha":null,"homepage":"","language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psd-tools.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-24T07:11:33.000Z","updated_at":"2025-05-17T10:29:23.000Z","dependencies_parsed_at":"2025-06-28T02:35:23.274Z","dependency_job_id":"053e54ec-eba9-4d0b-8cb2-c64866f78172","html_url":"https://github.com/psd-tools/image-blender","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/psd-tools/image-blender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psd-tools%2Fimage-blender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psd-tools%2Fimage-blender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psd-tools%2Fimage-blender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psd-tools%2Fimage-blender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psd-tools","download_url":"https://codeload.github.com/psd-tools/image-blender/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psd-tools%2Fimage-blender/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267977451,"owners_count":24175161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blend-modes","blending","chops","composition","imagechops","images","layers","photoshop","python"],"created_at":"2025-06-01T09:38:31.184Z","updated_at":"2025-07-31T02:13:33.254Z","avatar_url":"https://github.com/psd-tools.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"=============\nimage-blender\n=============\n\n``image-blender`` is a Python extension which provides a fast implementation of\nAdobe Photoshop's blend modes. It is written using Cython. It was supposed to be\na helper module for psd-tools_ package back in 2015, but ended up in release hell\nas I've lost an inspiration.\n\n|Status| |PyPI|\n\n.. _psd-tools: https://github.com/psd-tools/psd-tools\n\n.. |Status| image:: https://img.shields.io/pypi/status/image-blender?label=Status\n            :alt: Development status\n\n.. |PyPI| image:: https://img.shields.io/pypi/v/image-blender?label=PyPI\n          :target: https://pypi.org/project/image-blender/\n          :alt: PyPI version\n\nUsage\n-----\n``image-blender`` is not a complete solution, it only provides you with blend\nfunctions themselves, so you can blend two images together. You should use some\nadditional Python package to work with images and alpha-composite them (e.g.\nPillow_ or pymaging_).\n\n.. _Pillow: https://github.com/python-pillow/Pillow\n.. _pymaging: https://github.com/ojii/pymaging\n\nThere are some requirements that should be met to apply a blend function to a\npair of images:\n\n1. Blend functions work with bytes, so you must pass a raw image data into them;\n2. Both images must be in ``RGBA`` mode and have the same size;\n3. Both images must have a bit depth of 32 bits (8 bits per channel).\n\nLet's take a look at some use cases, but first let's define one helper\nfunction and make some preparations. From now on it's assumed you're using\nPillow and all of the above requirements are already met:\n\n.. code:: python\n   :number-lines:\n\n   from PIL import Image\n   import image_blender\n\n   def apply_opacity(im, opacity):\n       if opacity == 255:\n           return im\n\n       alpha_index = len(im.mode) - 1\n       a = im.split()[alpha_index]\n       opacity_scale = opacity / 255\n       a = a.point(lambda i: i * opacity_scale)\n       im.putalpha(a)\n       return im\n\n   image_bottom = Image.open(\"image1.png\")\n   image_top = Image.open(\"image2.png\")\n\n   opacity = 200\n\nThe above function applies a constant opacity to an image with existing\nalpha channel. Now let's go to the examples:\n\n* Blend two images using ``Normal`` mode with some opacity:\n\n  .. code:: python\n     :number-lines: 20\n\n     # apply opacity to the top image first...\n     image_top = apply_opacity(image_top, opacity)\n     # ... then simply alpha-composite them, no blend function is needed...\n     result = Image.alpha_composite(image_bottom, image_top)\n\n     result.save(\"normal_with_opacity.png\")\n\n* Blend two images using ``Multiply`` mode (without opacity):\n\n  .. code:: python\n     :number-lines: 20\n\n     # apply a blend function to a raw image data...\n     tmp_top_bytes = image_blender.multiply(image_bottom.tobytes(), image_top.tobytes())\n     # ... then create a new Image object from the resulting data...\n     # Note: Images' sizes are the same.\n     tmp_top = Image.frombytes(\"RGBA\", image_top.size, tmp_top_bytes)\n     # ... finally, alpha-composite a new top image with a bottom one...\n     #\n     # Note: In these examples images have an alpha channel.\n     #       That's why we still need to alpha-composite them!\n     result = Image.alpha_composite(image_bottom, tmp_top)\n\n     result.save(\"multiply.png\")\n\n* Blend two images using ``Multiply`` mode with some opacity:\n\n  .. code:: python\n     :number-lines: 20\n\n     # simply combine the above examples...\n     image_top = apply_opacity(image_top, opacity)\n     tmp_top_bytes = image_blender.multiply(image_bottom.tobytes(), image_top.tobytes())\n     tmp_top = Image.frombytes(\"RGBA\", image_top.size, tmp_top_bytes)\n     result = Image.alpha_composite(image_bottom, tmp_top)\n\n     result.save(\"multiply_with_opacity.png\")\n\n* Blend two images using ``Dissolve`` mode with some opacity:\n\n  .. code:: python\n     :number-lines: 20\n\n     image_top = apply_opacity(image_top, opacity)\n     result_bytes = image_blender.dissolve(image_bottom.tobytes(), image_top.tobytes())\n     result = Image.frombytes(\"RGBA\", image_top.size, result_bytes)\n     # This one is a bit different here:\n     # you should NOT alpha-composite the images when using Dissolve mode!\n\n     result.save(\"dissolve_with_opacity.png\")\n\nLicense\n-------\nCopyright 2015-2023 Evgeny Kopylov. Licensed under the `MIT License`_.\n\n.. _`MIT License`: https://github.com/psd-tools/image-blender/blob/master/LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsd-tools%2Fimage-blender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsd-tools%2Fimage-blender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsd-tools%2Fimage-blender/lists"}