Repository: python-pillow/Pillow

Issue:
docstring in "Image.alpha_composite" is wrong
```python
def alpha_composite(self, im, dest=(0,0), source=(0,0)):
   """ 'In-place' analog of Image.alpha_composite. Composites an image
   onto this image.
    
   :param im: image to composite over this one
   :param dest: Optional 2 tuple (top, left) specifying the upper
   left corner in this (destination) image.
   :param source: Optional 2 (top, left) tuple for the upper left
   corner in the overlay source image, or 4 tuple (top, left, bottom,
   right) for the bounds of the source rectangle
    
   Performance Note: Not currently implemented in-place in the core layer.
   """
```
the func's param, "dest" and "source", should be (left, top) tuple, because:
```python
# line num 1416 of Image.py
box = dest + (dest[0] + overlay.width, dest[1] + overlay.height)
```
dest[0] will add overlay.width, so index 0 should be left coordinate, index 1 is top coordinate
and:
```python
# line num 1413 of Image.py
overlay = im.crop(source)
# line num 1422 of Image.py
background = self.crop(box)
```
Image.crop's param should be a (left, top, right, bottom) tuple.
so there is wrong in docstring of the func



Discussion:
Right. This is what you get when you translate x0,y0 in a rush. 

Resolving patch:
diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -1069,7 +1069,7 @@ def _crop(self, im, box):
         _decompression_bomb_check((x1, y1))
 
         return im.crop((x0, y0, x1, y1))
-         
+
     def draft(self, mode, size):
         """
         Configures the image file loader so it returns a version of the
@@ -1381,12 +1381,12 @@ def alpha_composite(self, im, dest=(0,0), source=(0,0)):
         onto this image.
 
         :param im: image to composite over this one
-        :param dest: Optional 2 tuple (top, left) specifying the upper
+        :param dest: Optional 2 tuple (left, top) specifying the upper
           left corner in this (destination) image.
-        :param source: Optional 2 (top, left) tuple for the upper left
-          corner in the overlay source image, or 4 tuple (top, left, bottom,
-          right) for the bounds of the source rectangle
-          
+        :param source: Optional 2 (left, top) tuple for the upper left
+          corner in the overlay source image, or 4 tuple (left, top, right,
+          bottom) for the bounds of the source rectangle
+
         Performance Note: Not currently implemented in-place in the core layer.
         """
 
@@ -1406,7 +1406,7 @@ def alpha_composite(self, im, dest=(0,0), source=(0,0)):
         if len(source) == 2:
             source = source + im.size
 
-        # over image, crop if it's not the whole thing. 
+        # over image, crop if it's not the whole thing.
         if source == (0,0) + im.size:
             overlay = im
         else:
@@ -1414,16 +1414,16 @@ def alpha_composite(self, im, dest=(0,0), source=(0,0)):
 
         # target for the paste
         box = dest + (dest[0] + overlay.width, dest[1] + overlay.height)
-            
+
         # destination image. don't copy if we're using the whole image.
         if dest == (0,0) + self.size:
             background = self
         else:
             background = self.crop(box)
-                        
+
         result = alpha_composite(background, overlay)
         self.paste(result, box)
-        
+
     def point(self, lut, mode=None):
         """
         Maps this image through a lookup table or function.


Test patch: