title: Outline around non-transparent image parts
body: <p>I'm trying to do an image outline in PIL. My goal is to have text with some extra lines that will be visible on any background (including images, not just solid colours), kinda like outlined movie subtitles.</p>
  
  <p>There are many answers here and texts on the web, but none of them work for me. They boil down to:</p>
  
  <ol>
  <li><p>(usually for text) Do <code>for</code>-loops to put text to positions <code>(x+dx, y+dy)</code> for <code>dx</code>, <code>dx</code> in <code>range(-radius, radius + 1)</code>.</p></li>
  <li><p>Blur the image.</p></li>
  <li><p>Make a contour and draw it with a thick line.</p></li>
  <li><p>Edge-detect algorithms.</p></li>
  </ol>
  
  <p>I tried these, but the quality of the results was bad. This is for a project that really needs to look professional.</p>
  
  <p>If I was doing this in Gimp, I would likely select the transparent part of the image with "Select by Color" tool, then invert the selection (to select everything that's not transparent), then grow the selection (giving me nicely rounded shape around corners), then feather it a bit (to get smoother lines), and then paint it with a solid colour, on a layer below my image.</p>
  
  <p>Is it possible to do something like this in PIL, or anything compatible (basically, anything that can take NumPy array "images")?</p>