Skip to content

Commit

Permalink
Use different parameter than the existing interface
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredfool committed Nov 13, 2017
1 parent dce04b6 commit 68b960c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,8 @@ def thumbnail(self, size, resample=BICUBIC):

# FIXME: the different transform methods need further explanation
# instead of bloating the method docs, add a separate chapter.
def transform(self, size, method, data=None, resample=NEAREST, fill=None):
def transform(self, size, method, data=None, resample=NEAREST,
fill=1, fillcolor=None):
"""
Transforms this image. This method creates a new image with the
given size, and the same mode as the original, and copies data
Expand All @@ -2095,7 +2096,7 @@ def transform(self, size, method, data=None, resample=NEAREST, fill=None):
environment), or :py:attr:`PIL.Image.BICUBIC` (cubic spline
interpolation in a 4x4 environment). If omitted, or if the image
has mode "1" or "P", it is set to :py:attr:`PIL.Image.NEAREST`.
:param fill: Optional fill color for the area outside the transform
:param fillcolor: Optional fill color for the area outside the transform
in the output image.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
Expand All @@ -2109,7 +2110,6 @@ def transform(self, size, method, data=None, resample=NEAREST, fill=None):
size, method, data, resample, fill).convert('RGBA')

if isinstance(method, ImageTransformHandler):
fill = 1
return method.transform(size, self, resample=resample, fill=fill)

if hasattr(method, "getdata"):
Expand All @@ -2119,13 +2119,15 @@ def transform(self, size, method, data=None, resample=NEAREST, fill=None):
if data is None:
raise ValueError("missing method data")

im = new(self.mode, size, fill)
im = new(self.mode, size, fillcolor)
if method == MESH:
# list of quads
for box, quad in data:
im.__transformer(box, self, QUAD, quad, resample, fill is None)
im.__transformer(box, self, QUAD, quad, resample,
fillcolor is None)
else:
im.__transformer((0, 0)+size, self, method, data, resample, fill is None)
im.__transformer((0, 0)+size, self, method, data,
resample, fillcolor is None)

return im

Expand Down

0 comments on commit 68b960c

Please sign in to comment.