title: Merging background with transparent image in PIL
body: <p>I have a png image as background and I want to add a transparent mesh to this background but this doesn't work as expected. The background image is converted to transparent on places where I apply transparent mesh.</p>
  
  <p>I am doing:</p>
  
  <pre><code>from PIL import Image, ImageDraw
  
  map_background = Image.open(MAP_BACKGROUND_FILE).convert('RGBA')
  map_mesh = Image.new('RGBA', (width, height), (0, 0, 0, 0))
  draw = ImageDraw.Draw(map_mesh)
  
  # Create mesh using: draw.line([...], fill=(255, 255, 255, 50), width=1)
  ...
  
  map_background.paste(map_mesh, (0, 0), map_mesh)
  </code></pre>
  
  <p>But the result is:</p>
  
  <p><img src="https://i.stack.imgur.com/wp5Uh.jpg" alt="enter image description here"></p>
  
  <p>You can see a chessboard pattern if you look carefully (used in graphics programs as no background). Transparent lines makes the background layer transparent too in places where both layers met. But I only want the transparent line to be added on top of the background.</p>
  
  <p>I can solve it with:</p>
  
  <pre><code>map_background.paste((255,255,255), (0, 0), map_mesh)
  </code></pre>
  
  <p>but as I use different colors for different lines, I would have to make for every color this process. If I had 100 colors, then I need 100 layers what is not very good solution.</p>