Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for RGBA PSD images #6481

Merged
merged 1 commit into from Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added Tests/images/rgba.psd
Binary file not shown.
7 changes: 6 additions & 1 deletion Tests/test_file_psd.py
Expand Up @@ -4,7 +4,7 @@

from PIL import Image, PsdImagePlugin

from .helper import assert_image_similar, hopper, is_pypy
from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy

test_file = "Tests/images/hopper.psd"

Expand Down Expand Up @@ -107,6 +107,11 @@ def test_open_after_exclusive_load():
im.load()


def test_rgba():
with Image.open("Tests/images/rgba.psd") as im:
assert_image_equal_tofile(im, "Tests/images/imagedraw_square.png")


def test_icc_profile():
with Image.open(test_file) as im:
assert "icc_profile" in im.info
Expand Down
3 changes: 3 additions & 0 deletions src/PIL/PsdImagePlugin.py
Expand Up @@ -75,6 +75,9 @@ def _open(self):

if channels > psd_channels:
raise OSError("not enough channels")
if mode == "RGB" and psd_channels == 4:
mode = "RGBA"
channels = 4

self.mode = mode
self._size = i32(s, 18), i32(s, 14)
Expand Down