mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Move the scale function from Image to ImageOps
This commit is contained in:
parent
ea00713099
commit
c0eb87cac3
20
PIL/Image.py
20
PIL/Image.py
|
@ -1547,26 +1547,6 @@ class Image(object):
|
|||
|
||||
return self._new(self.im.resize(size, resample))
|
||||
|
||||
def scale(self, factor, resample = NEAREST):
|
||||
"""
|
||||
Returns a rescaled image by a specific factor given in parameter.
|
||||
A factor greater than 1 expands the image, between 0 and 1 contracts the
|
||||
image.
|
||||
|
||||
:param factor: The expansion factor, as a float.
|
||||
:param resample: An optional resampling filter. Same values possible as
|
||||
in the PIL.Image.resize function.
|
||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||
"""
|
||||
if factor == 1:
|
||||
return self._new(self.im)
|
||||
elif factor <= 0:
|
||||
raise ValueError("the factor must be greater than 0")
|
||||
else:
|
||||
size = (int(round(factor * self.width)),
|
||||
int(round(factor * self.height)))
|
||||
return self.resize(size, resample)
|
||||
|
||||
def rotate(self, angle, resample=NEAREST, expand=0):
|
||||
"""
|
||||
Returns a rotated copy of this image. This method returns a
|
||||
|
|
|
@ -178,6 +178,27 @@ def crop(image, border=0):
|
|||
)
|
||||
|
||||
|
||||
def scale(self, factor, resample=Image.NEAREST):
|
||||
"""
|
||||
Returns a rescaled image by a specific factor given in parameter.
|
||||
A factor greater than 1 expands the image, between 0 and 1 contracts the
|
||||
image.
|
||||
|
||||
:param factor: The expansion factor, as a float.
|
||||
:param resample: An optional resampling filter. Same values possible as
|
||||
in the PIL.Image.resize function.
|
||||
:returns: An :py:class:`~PIL.Image.Image` object.
|
||||
"""
|
||||
if factor == 1:
|
||||
return self._new(self.im)
|
||||
elif factor <= 0:
|
||||
raise ValueError("the factor must be greater than 0")
|
||||
else:
|
||||
size = (int(round(factor * self.width)),
|
||||
int(round(factor * self.height)))
|
||||
return self.resize(size, resample)
|
||||
|
||||
|
||||
def deform(image, deformer, resample=Image.BILINEAR):
|
||||
"""
|
||||
Deform the image.
|
||||
|
|
Loading…
Reference in New Issue
Block a user