Skip to content

Convert LA images when pasting into RGB images - #10525

Merged
radarhere merged 3 commits into
python-pillow:mainfrom
tony1233200:fix/paste-la-into-rgb
Nov 16, 2026
Merged

radarhere merged 3 commits into
python-pillow:mainfrom
tony1233200:fix/paste-la-into-rgb

Conversation

@tony1233200

Copy link
Copy Markdown
Contributor

Fixes #10524.

Changes proposed in this pull request:

  • Image.paste() skipped conversion for LA images pasted into RGB images, copying the stored bytes directly. That assumed the two padding bytes of an LA pixel hold copies of the L value, but Image.merge() and point() leave them as zero (and Set padding bytes in new 2 channel images to zero #10511 zeroes them for Image.new() as well), so a grey LA pixel pasted as red, e.g. (128, 0, 0) instead of (128, 128, 128). LA is now converted like other modes when pasting into RGB; RGBA and RGBa keep the direct copy, since their first three stored bytes really are R, G and B.
  • Added a test pasting LA images created by Image.new(), Image.merge() and point() into an RGB image. The test fails without the Image.py change and passes with it.
  • Added a release note.

Test results: Tests/test_image_paste.py (61 passed), plus Tests/test_image.py, Tests/test_image_convert.py and Tests/test_image_point.py (274 passed, 2 skipped for unavailable features).

This change was prepared with the help of an AI coding assistant.

@radarhere radarhere added the 🤖-assisted AI-assisted label Nov 16, 2026
@radarhere
radarhere enabled auto-merge (squash) November 16, 2026 19:46
@radarhere
radarhere merged commit 6740faf into python-pillow:main Nov 16, 2026
73 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An LA image from Image.merge() or point() is pasted onto an RGB image as red

2 participants