Skip to content

Commit 38e411d

Browse files
authored
Merge pull request #6481 from radarhere/psd_rgba
Added support for RGBA PSD images
2 parents 3b0f046 + e77a7b6 commit 38e411d

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

Tests/images/rgba.psd

2.39 KB
Binary file not shown.

Tests/test_file_psd.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from PIL import Image, PsdImagePlugin
66

7-
from .helper import assert_image_similar, hopper, is_pypy
7+
from .helper import assert_image_equal_tofile, assert_image_similar, hopper, is_pypy
88

99
test_file = "Tests/images/hopper.psd"
1010

@@ -107,6 +107,11 @@ def test_open_after_exclusive_load():
107107
im.load()
108108

109109

110+
def test_rgba():
111+
with Image.open("Tests/images/rgba.psd") as im:
112+
assert_image_equal_tofile(im, "Tests/images/imagedraw_square.png")
113+
114+
110115
def test_icc_profile():
111116
with Image.open(test_file) as im:
112117
assert "icc_profile" in im.info

src/PIL/PsdImagePlugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def _open(self):
7575

7676
if channels > psd_channels:
7777
raise OSError("not enough channels")
78+
if mode == "RGB" and psd_channels == 4:
79+
mode = "RGBA"
80+
channels = 4
7881

7982
self.mode = mode
8083
self._size = i32(s, 18), i32(s, 14)

0 commit comments

Comments
 (0)