one problem generating transparent png text.
Posted: Sun Nov 09, 2008 5:48 pm
Hello to all in this community!
Based on info found from several sources, i wrote this little script to write transparent images with a specific font:
The script works like a charm, but it has one issue with italic or handwritten fonts; the resulting png has a transparent background, but it seems that at the moment to write each letter, it writes it erasing all what is behind the white space of the letter, generatin a blank square deleting all what is behind. I dont know if im explaining well, but here is and example, this is my working script with a handwritting font:
http://roselly.destrella.com.mx/wp-cont ... qrstuvwxyz
but it should work like this (this sample is from the dafont.com website where i've downloaded the font):
http://img.dafont.com/preview.php?text= ... ize=m&y=54
(copy & paste the dafont.com link if doesnt work just clicking on it)
as you can see, both scripts works with the same font but something seems to be missing on mine; so the question here is, how to make it work properly? where is the mistake and how to solve it?
thanks in advance for your time and help
Based on info found from several sources, i wrote this little script to write transparent images with a specific font:
Code: Select all
<?
header ("Content-type: image/png");
$Fuente = "english.ttf";
$r=255;
$g=153;
$b=255;
$Dimension = imageTTFBBox($Tamanio, 0, $Fuente, $Texto);
$Imagen = imageCreateTrueColor(abs($Dimension[2]) + abs($Dimension[0]), abs($Dimension[7]) + abs($Dimension[1]));
imageSaveAlpha($Imagen, true);
ImageAlphaBlending($Imagen, false);
$Transparencia = imagecolorallocatealpha($Imagen, $r, $g, $b, 127);
imagefill($Imagen, 0, 0, $Transparencia);
$Color = imagecolorallocate($Imagen, $r, $g, $b);
imagettftext($Imagen, $Tamanio, 0, 0, abs($Dimension[5]), $Color, $Fuente, $Texto);
imagepng($Imagen);
imagedestroy($Imagen);
?>http://roselly.destrella.com.mx/wp-cont ... qrstuvwxyz
but it should work like this (this sample is from the dafont.com website where i've downloaded the font):
http://img.dafont.com/preview.php?text= ... ize=m&y=54
(copy & paste the dafont.com link if doesnt work just clicking on it)
as you can see, both scripts works with the same font but something seems to be missing on mine; so the question here is, how to make it work properly? where is the mistake and how to solve it?
thanks in advance for your time and help