title: Use PIL to recolor a monochrome image and preserve transparency
body: <p>I am creating an app using python and I need to be able to colorize a PIL Image. I have several images similar to the following:<br><br>
  <a href="https://i.stack.imgur.com/4f4kp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4f4kp.png" alt="black photo"></a></p>
  
  <p>I want to be able to change the color of this icon easily based on a certain color in the color scheme defined as such</p>
  
  <pre><code>colorScheme = {
      "mainBackground": "#222426",
      "axis": "#323538",
      "dimTips": "#8d9096",
      "viewLayer": "blue",
      "editLayer": "red",
      "toolBackground": "#313336",
      "toolOutline": "#1c1d1f"
  }
  </code></pre>
  
  <p>I specifically want to set it based on the <code>"dimTips"</code> option.
  <br>
  The images are referenced as follows so it is ideal to have an inline solution</p>
  
  <pre><code>self.icons = {
              "unlock": ImageTk.PhotoImage(Image.open("icons/unlock.png")),
              "locked": ImageTk.PhotoImage(Image.open("icons/locked.png"))
  }
  </code></pre>
  
  <p>In theory this is easy to do but I want an option that preserves transparency and is not overkill.</p>