php - Transparent Overlay Creating PNG -
i have below function , i've gotten size need, i'm adding background image , looking add text overlay transparent background on overlay text imagefilledrectangle
applies variable $white
expected, i'm trying see if there anyway tell function transparent instead of accepting colour, white in instance, php docs colour required parameter imagefilledrectangle
, suggestions appreciated.
the background image local image:
define("background_file", "background.png");
function:
public function generateimage() { if (file_exists(background_file)) { $im = @imagecreatefrompng(background_file); if($im) { $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 115, 150, 195); imagefilledrectangle($im, 0, 0, 399, 29, $white); $text = 'test'; $font = 'arial_narrow_7.ttf'; imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagepng($im); imagedestroy($im); } else { echo 'error'; } } }
i tried adding imagecolortransparent($im, $white);
before imagefilledrectangle
didn't make difference.
figured out, there no need have imagefilledrectangle
line in function, below gives transparent overlay text elements no fill being applied.
public function generateimage() { if (file_exists(background_file)) { $im = @imagecreatefrompng(background_file); if($im) { $black = imagecolorallocate($im, 115, 150, 195); $text = 'test'; $font = 'arial_narrow_7.ttf'; imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagepng($im); imagedestroy($im); } else { echo 'error'; } } }
Comments
Post a Comment