title: how to draw semi-transparent rectangle in php?
body: <p>Here is an example what I would like to do:</p>
  
  <p><img src="https://i.stack.imgur.com/IgILx.jpg" alt="enter image description here"></p>
  
  <p>Here is the result:</p>
  
  <pre><code>function red_rectangle($img_src,$x1,$y1,$x2,$y2,$tr = 50)
  {
      // Load image
      $img = imagecreatefromjpeg($img_src);
      // Transparent red
      $red = imagecolorallocatealpha($img, 255, 0, 0, $tr);
      // Draw a white rectangle
      imagefilledrectangle($img, $x1, $y1, $x2, $y2, $red);
      // Save the image (overwrite)
      imagejpeg($img, $img_src);
      imagedestroy($img);
  }
  </code></pre>