title: How to use PIL paste with mask?
body: <p>I am trying to use PIL <code>paste()</code> function. I want to put in a mask as well but I keep getting this error:</p>
  
  <blockquote>
    <p>ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()</p>
  </blockquote>
  
  <pre><code>canvases[0].paste(mnist_images[i],
                    box=tuple(map(lambda p: int(round(p)), positions[i])), mask=mask)
  </code></pre>
  
  <p>The code works without a mask. Mask is a numpy array. I have not seen an example with mask and the documentation is not clear.</p>
  
  <p><a href="https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.paste" rel="noreferrer">https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.paste</a></p>
  
  <blockquote>
    <p>If a mask is given, this method updates only the regions indicated by the mask. You can use either <code>"1"</code>, <code>"L"</code>, or <code>"RGBA"</code> images (in the latter case, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate values will mix the two images together, including their alpha channels if they have them.</p>
  </blockquote>
  
  <p>I dont have RGBA so how do I use <code>"1"</code> or <code>"L"</code>?</p>