diff --git a/PIL/Image.py b/PIL/Image.py index bcc94af9d..e2e80a82a 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1032,6 +1032,9 @@ class Image(object): x0, y0, x1, y1 = map(int, map(round, box)) + if x0 == 0 and y0 == 0 and (x1, y1) == self.size: + return self.copy() + if x1 < x0: x1 = x0 if y1 < y0: @@ -1520,16 +1523,16 @@ class Image(object): def remap_palette(self, dest_map, source_palette=None): """ Rewrites the image to reorder the palette. - + :param dest_map: A list of indexes into the original palette. e.g. [1,0] would swap a two item palette, and list(range(255)) is the identity transform. :param source_palette: Bytes or None. - :returns: An :py:class:`~PIL.Image.Image` object. - + :returns: An :py:class:`~PIL.Image.Image` object. + """ from . import ImagePalette - + if self.mode not in ("L", "P"): raise ValueError("illegal image mode") @@ -1538,7 +1541,7 @@ class Image(object): source_palette = self.im.getpalette("RGB")[:768] else: # L-mode source_palette = bytearray(i//3 for i in range(768)) - + palette_bytes = b"" new_positions = [0]*256 @@ -1591,8 +1594,8 @@ class Image(object): size=len(palette_bytes)) return m_im - - + + def resize(self, size, resample=NEAREST): """ @@ -2615,7 +2618,7 @@ def register_decoder(name, decoder): :param decoder: A callable(mode, args) that returns an ImageFile.PyDecoder object - .. versionadded:: 4.1.0 + .. versionadded:: 4.1.0 """ DECODERS[name] = decoder