mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Do not attempt normalization if image is already normal
This commit is contained in:
parent
243402e78e
commit
b8cd3e72a6
|
@ -38,6 +38,12 @@ def test_sanity():
|
|||
convert(im, output_mode)
|
||||
|
||||
|
||||
def test_unsupported_conversion():
|
||||
im = hopper()
|
||||
with pytest.raises(ValueError):
|
||||
im.convert("INVALID")
|
||||
|
||||
|
||||
def test_default():
|
||||
|
||||
im = hopper("P")
|
||||
|
|
|
@ -1036,7 +1036,10 @@ class Image:
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user