mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 03:21:44 +03:00
Simplified casts
This commit is contained in:
parent
4d9fdac92f
commit
99666dac29
|
@ -1113,7 +1113,7 @@ class Image:
|
||||||
if trns is not None:
|
if trns is not None:
|
||||||
try:
|
try:
|
||||||
new_im.info["transparency"] = new_im.palette.getcolor(
|
new_im.info["transparency"] = new_im.palette.getcolor(
|
||||||
cast(Tuple[int, int, int], trns), # trns was converted to RGB
|
cast(Tuple[int, ...], trns), # trns was converted to RGB
|
||||||
new_im,
|
new_im,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -1163,12 +1163,9 @@ class Image:
|
||||||
# crash fail if we leave a bytes transparency in an rgb/l mode.
|
# crash fail if we leave a bytes transparency in an rgb/l mode.
|
||||||
del new_im.info["transparency"]
|
del new_im.info["transparency"]
|
||||||
if trns is not None:
|
if trns is not None:
|
||||||
if new_im.mode == "P":
|
if new_im.mode == "P" and new_im.palette:
|
||||||
try:
|
try:
|
||||||
new_im.info["transparency"] = new_im.palette.getcolor(
|
new_im.info["transparency"] = new_im.palette.getcolor(trns, new_im)
|
||||||
cast(Tuple[int, int, int], trns), # trns was converted to RGB
|
|
||||||
new_im,
|
|
||||||
)
|
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
del new_im.info["transparency"]
|
del new_im.info["transparency"]
|
||||||
if str(e) != "cannot allocate more than 256 colors":
|
if str(e) != "cannot allocate more than 256 colors":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user