If image is already in the destination mode and there is no matrix, do not convert

This commit is contained in:
Andrew Murray 2017-09-06 14:49:15 +10:00
parent 411765a69c
commit d8c088ed8b

View File

@ -871,18 +871,16 @@ class Image(object):
:returns: An :py:class:`~PIL.Image.Image` object. :returns: An :py:class:`~PIL.Image.Image` object.
""" """
if not mode: self.load()
if not mode and self.mode == "P":
# determine default mode # determine default mode
if self.mode == "P": if self.palette:
self.load() mode = self.palette.mode
if self.palette:
mode = self.palette.mode
else:
mode = "RGB"
else: else:
return self.copy() mode = "RGB"
else: if not mode or (mode == self.mode and not matrix):
self.load() return self.copy()
if matrix: if matrix:
# matrix conversion # matrix conversion