From 42086c3a353a0abfb8b64f6f2b6c9140af942877 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Fri, 5 Jan 2018 10:08:35 +0000 Subject: [PATCH] Typing: Image.alphacomposite --- src/PIL/Image.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 71d7fbd85..6d5536035 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1522,17 +1522,22 @@ class Image(object): if min(dest) < 0: raise ValueError("Destination must be non-negative") + source_lurd = None # type: LURD + if len(source) == 2: - source = source + im.size + source_lurd = source + im.size # type: ignore + else: + source_lurd = source # type: ignore # over image, crop if it's not the whole thing. - if source == (0,0) + im.size: + if source_lurd == (0,0) + im.size: overlay = im else: - overlay = im.crop(source) + overlay = im.crop(source_lurd) # target for the paste - box = dest + (dest[0] + overlay.width, dest[1] + overlay.height) + box = None # type: LURD + box = dest + (dest[0] + overlay.width, dest[1] + overlay.height) # type: ignore # destination image. don't copy if we're using the whole image. if box == (0,0) + self.size: @@ -2338,8 +2343,9 @@ class Image(object): class ImagePointHandler(object): # used as a mixin by point transforms (for use with im.point) - pass - + def point(self, s): + # type (T) -> T + return s class ImageTransformHandler(object): # used as a mixin by geometry transforms (for use with im.transform)