title: Why does this transparent PNG cause borders when combined using GD?
body: <p>I am trying to create an image from an another image using PHP. Here is my code:</p>
  
  <pre><code>&lt;?php
      $width = 109;
      $height = 109;
      $image = imagecreatetruecolor($width, $height);
      $source_under = imagecreatefrompng('ecloid_under.png');
      $black = imagecolorallocate($image, 0x00, 0x00, 0x00);
  
      imagecolortransparent($image, $black);
  
      imagecopy($image, $source_under, 0, 0, 0, 0, $width, $height);
  
      header('Content-type: image/png');
      imagepng($image);
      imagedestroy($image);
  ?&gt;
  </code></pre>
  
  <p>So I am loading this image in <code>$source_under</code></p>
  
  <p><img src="https://i.stack.imgur.com/hAXHk.png" alt="enter image description here"></p>
  
  <p>and copying it over a transparent blank "canvas" image. Here is the result of that operation:</p>
  
  <p><img src="https://i.stack.imgur.com/IZc3u.png" alt="enter image description here"></p>
  
  <p>As can be seen, there is a sort of black border around the whole initial image. I think this is due to the fact that initially, the "canvas" image is all black. So there is something wrong with the transparency and the anti-aliasing of the image.</p>
  
  <p>This isn't the first time I have a similar problem, but last time the source image was the cause. This time around, opening it in Photoshop does not show any potential problems with it.</p>
  
  <p>Does anyone know how to fix this?</p>