Skip to content

Commit

Permalink
Merge pull request #5315 from radarhere/simplified
Browse files Browse the repository at this point in the history
Simplified code
  • Loading branch information
radarhere committed Jun 30, 2021
2 parents 81f4266 + 0a56d9b commit cab9179
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/PIL/Image.py
Expand Up @@ -1975,7 +1975,7 @@ def resize(self, size, resample=None, box=None, reducing_gap=None):
resample = NEAREST

if self.mode in ["LA", "RGBA"] and resample != NEAREST:
im = self.convert(self.mode[:-1] + "a")
im = self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode])
im = im.resize(size, resample, box)
return im.convert(self.mode)

Expand Down Expand Up @@ -2025,7 +2025,7 @@ def reduce(self, factor, box=None):
return self.copy()

if self.mode in ["LA", "RGBA"]:
im = self.convert(self.mode[:-1] + "a")
im = self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode])
im = im.reduce(factor, box)
return im.convert(self.mode)

Expand Down Expand Up @@ -2463,18 +2463,11 @@ def getdata(self):
:returns: An :py:class:`~PIL.Image.Image` object.
"""

if self.mode == "LA" and resample != NEAREST:
if self.mode in ("LA", "RGBA") and resample != NEAREST:
return (
self.convert("La")
self.convert({"LA": "La", "RGBA": "RGBa"}[self.mode])
.transform(size, method, data, resample, fill, fillcolor)
.convert("LA")
)

if self.mode == "RGBA" and resample != NEAREST:
return (
self.convert("RGBa")
.transform(size, method, data, resample, fill, fillcolor)
.convert("RGBA")
.convert(self.mode)
)

if isinstance(method, ImageTransformHandler):
Expand Down

0 comments on commit cab9179

Please sign in to comment.