Skip to content

Commit

Permalink
Do not attempt normalization if image is already normal
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 6, 2022
1 parent 243402e commit 8c59a9d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/PIL/Image.py
Expand Up @@ -1036,7 +1036,10 @@ def convert_transparency(m, v):
except ValueError:
try:
# normalize source image and try again
im = self.im.convert(getmodebase(self.mode))
modebase = getmodebase(self.mode)
if modebase == self.mode:
raise
im = self.im.convert(modebase)
im = im.convert(mode, dither)
except KeyError as e:
raise ValueError("illegal conversion") from e
Expand Down

0 comments on commit 8c59a9d

Please sign in to comment.