note 100184 deleted from function.imagettftext by cmb

From: Date: Sun, 28 Jul 2019 08:18:57 +0000
Subject: note 100184 deleted from function.imagettftext by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211738@lists.php.net to get a copy of this message
Note Submitter: eee ess c p 9 9 AT yahoo DOT com ---- If you get letters cut off (clipped) by adjacent letters when using imagettftext with transparency (i.e., imagealphablending set to false), try setting imagealphablending back to TRUE before calling the imagettftext function. <?php $im = imagecreatetruecolor(300, 300); imagealphablending($im, false); imagesavealpha($im, true); // Create colors and draw transparent background $trans = imagecolorallocatealpha($im, 255, 255, 255, 127); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 299, 299, $trans); // Bad text imagettftext($im, 22, 0, 50, 100, $black, 'arial.ttf', 'Bad: Oj Pj wj'); // Good text imagealphablending($im, true); imagettftext($im, 22, 0, 50, 150, $black, 'arial.ttf', 'Good: Oj Pj wj'); /*** You'll need a copy of the arial.ttf font file in the same location as the PHP script ***/ // Output PNG header("Content-type: image/png"); imagepng($im); imagedestroy($im); ?>

« previous php.notes (#211738) next »