title: How to add a transparent rectangle to PNG file in php WITHOUT a border
body: <p>I can successfully add a transparent rectangle to an area of a saved PNG file, but it has a faint border around it, which can be seen on the final image. I want to remove this.</p>
  
  <p>The code I use to add the rectangle is:</p>
  
  <pre><code>$dest=imagecreatefrompng("originalFilename.png");
  $red = imagecolorallocate($dest, 255, 0, 0);
  imagecolortransparent($dest, $red);
  imagefilledrectangle($dest, 0, 0, 50, 25, $red);
  imagepng($dest, "newFilename.png");
  </code></pre>
  
  <p>and the result looks like this:
  <a href="https://i.stack.imgur.com/vvKCh.png" rel="nofollow noreferrer">Image showing rectangle outline</a></p>
  
  <p>The transparency works fine, showing in this example a white background behind... but you can see that in the top left there's the faint outline of the transparent rectangle. This is what I want to remove. </p>
  
  <p>I've since tried putting a box over the edge (it would be white to match the background of the image, but using green for display purposes here), but that box gets a slightly red huhe around it too!?!? Really strange. 
  Like this
  <a href="https://i.stack.imgur.com/aoQ1H.png" rel="nofollow noreferrer">red hue </a></p>
  
  <p>Grateful for any clues. This is not the same as the suggested duplicate as it deals specifically with the hue that's left around the border of the transparent area and also any object made to go in that area. </p>