title: PIL : PNG image as watermark for a JPG image
body: <p>I'm trying to make a composite image from a JPEG photo (1600x900) and a PNG logo with alpha channel (400x62).</p>
  
  <p>Here is a command that does the job with image magick:</p>
  
  <pre><code>composite -geometry +25+25 watermark.png original_photo.jpg watermarked_photo.jpg
  </code></pre>
  
  <p>Now I'd like to do something similar in a python script, without invoking this shell command externally, with PIL.</p>
  
  <p>Here is what I tried :</p>
  
  <pre><code>photo = Image.open('original_photo.jpg')
  watermark = Image.open('watermark.png')
  photo.paste(watermark, (25, 25))
  </code></pre>
  
  <p>The problem here is that the alpha channel is completely ignored and the result is as if my watermark were black and white rather than <code>rbga(0, 0, 0, 0)</code> and <code>rbga(255, 255, 255, 128)</code>.</p>
  
  <p>Indeed, <a href="https://pillow.readthedocs.io/en/4.1.x/reference/Image.html#PIL.Image.Image.paste" rel="noreferrer">PIL docs state</a> : "See alpha_composite() if you want to combine images with respect to their alpha channels."</p>
  
  <p>So I looked at <code>alpha_composite()</code>. Unfortunately, this function requires both images to be of the same size and mode.</p>