note 107237 modified in function.imagecolortransparent by danbrown

From: Date: Thu, 10 May 2012 21:35:44 +0000
Subject: note 107237 modified in function.imagecolortransparent by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187912@lists.php.net to get a copy of this message
A transparent background with text doesn't seem to work very well because of the antialiasing . But I tried the following kluge and it turned out very well:

<?php
 $im = imagecreatetruecolor(100,20);
 $almostblack = imagecolorallocate($im,254,254,254);
 imagefill($im,0,0,$almostblack);
 $black = imagecolorallocate($im,0,0,0);
 imagecolortransparent($im,$almostblack);
 //... set x and y..
 imagettftext($im,8,0,$x,$y,$black,"calibri.ttf",$txt);
?> --was-- A transparent background with text doesn't seem to work very well because of the antialiasing . But I tried the following kluge and it turned out very well: $im = imagecreatetruecolor(100,20); $almostblack = imagecolorallocate($im,254,254,254); imagefill($im,0,0,$almostblack); $black = imagecolorallocate($im,0,0,0); imagecolortransparent($im,$almostblack); ... set x and y.. imagettftext($im,8,0,$x,$y,$black,"calibri.ttf",$txt); http://php.net/manual/en/function.imagecolortransparent.php

« previous php.notes (#187912) next »