Merge pull request #3163 from radarhere/fillcolor

Fixed transform fillcolor argument when image mode is RGBA or LA
This commit is contained in:
Hugo 2018-06-14 09:25:00 +03:00 committed by GitHub
commit 48dda53c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -53,15 +53,20 @@ class TestImageTransform(PillowTestCase):
self.assert_image_equal(transformed, scaled)
def test_fill(self):
im = hopper('RGB')
(w, h) = im.size
transformed = im.transform(im.size, Image.EXTENT,
(0, 0,
w*2, h*2),
Image.BILINEAR,
fillcolor='red')
for mode, pixel in [
['RGB', (255, 0, 0)],
['RGBA', (255, 0, 0, 255)],
['LA', (76, 0)]
]:
im = hopper(mode)
(w, h) = im.size
transformed = im.transform(im.size, Image.EXTENT,
(0, 0,
w*2, h*2),
Image.BILINEAR,
fillcolor='red')
self.assertEqual(transformed.getpixel((w-1, h-1)), (255, 0, 0))
self.assertEqual(transformed.getpixel((w-1, h-1)), pixel)
def test_mesh(self):
# this should be a checkerboard of halfsized hoppers in ul, lr

View File

@ -2115,11 +2115,11 @@ class Image(object):
if self.mode == 'LA':
return self.convert('La').transform(
size, method, data, resample, fill).convert('LA')
size, method, data, resample, fill, fillcolor).convert('LA')
if self.mode == 'RGBA':
return self.convert('RGBa').transform(
size, method, data, resample, fill).convert('RGBA')
size, method, data, resample, fill, fillcolor).convert('RGBA')
if isinstance(method, ImageTransformHandler):
return method.transform(size, self, resample=resample, fill=fill)