Skip to content

Image.alpha_composite does not work with images of type "LA" #9051

@flagadum

Description

@flagadum

I do understand the status of "Limited support" of the "LA" mode, yet, alpha_composite should definitely be available as part basic functionality, along the fact that its implementation should be quite straightforward and similar to its "RGBA" mode variant.

What did you do?

Try to compose two images of mode "LA"

What did you expect to happen?

Get an image of mode "LA" as a result.

What actually happened?

Got an error message: image has wrong mode

What are your OS, Python and Pillow versions?

  • OS: MacOS
  • Python: 3.13.5
  • Pillow: 11.2.1
--------------------------------------------------------------------
Pillow 11.2.1
Python 3.13.5 (v3.13.5:6cb20a219a8, Jun 11 2025, 12:23:45) [Clang 16.0.0 (clang-1600.0.26.6)]
--------------------------------------------------------------------
Python executable is /usr/local/bin/python3
System Python files loaded from /Library/Frameworks/Python.framework/Versions/3.13
--------------------------------------------------------------------
Python Pillow modules loaded from /Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/PIL
Binary Pillow modules loaded from /Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.2.1
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.17
--- WEBP support ok, loaded 1.5.0
*** AVIF support not installed
--- JPEG support ok, compiled for libjpeg-turbo 3.1.0
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.7.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
--- XCB (X protocol) support ok
--------------------------------------------------------------------
#!/usr/bin/env python3                                                       


from PIL import Image

img_a = Image.new("LA",(100,100),(200,128))
img_b = Image.new("LA",(100,100),(240,128))

img =  Image.alpha_composite(img_a,img_b)

## Inefficient workaround
#img = Image.alpha_composite(img_a.convert("RGBA"),img_b.convert("RGBA")).convert("LA")

img.show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions