mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Return copy on Image crop if crop dimensions match Image dimensions
This commit is contained in:
parent
2152b26515
commit
4dd7b94338
19
PIL/Image.py
19
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user