title: Add border around png image using imagick PHP
body: <p>How can I add a border around a png image? Whenever I try to add a border using <a href="http://www.php.net/manual/en/imagick.borderimage.php" rel="noreferrer">borderImage</a> function available in <a href="http://www.php.net/manual/en/book.imagick.php" rel="noreferrer">imagick</a> it loses its transparency if it is a png image. </p>
  
  <pre><code>&lt;?php
  
  $image = new Imagick();
  $image-&gt;readImage('tux.png');
  
  $image-&gt;BorderImage(new ImagickPixel("red") , 5,5);
  
  // send the result to the browser
  header("Content-Type: image/" . $image-&gt;getImageFormat());
  echo $image;
  </code></pre>
  
  <p>This is the original image:</p>
  
  <p><img src="https://i.stack.imgur.com/ILTQq.png" alt="enter image description here"></p>
  
  <p>and this is after adding a border:</p>
  
  <p><img src="https://i.stack.imgur.com/OHJsh.png" alt="enter image description here"></p>
  
  <p>Border color is also applied onto the background. I want to do this using imagick 
  How can I apply a border to a transparent image without losing transparency? </p>