![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
14/12/2009, 14:09
|
![Avatar de thosecars82](http://static.forosdelweb.com/customavatars/avatar227788_3.gif) | | | Fecha de Ingreso: abril-2008
Mensajes: 32
Antigüedad: 16 años, 10 meses Puntos: 0 | |
write text to transparent image Does anybody know why this code is only working locally on xampp but not on remote server where I just see a black rectangle instead of the word "phone"?
You can check it at [url]http://www.arreglaordenador.com/numberimage4.php[/url]
Código:
<?php
$fontDir = $rootPath . "fonts\\";
header("Content-type: image/png"); //Picture Format
header("Expires: Mon, 01 Jul 2003 00:00:00 GMT"); // Past date
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Consitnuously modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // NO CACHE
/*image generation code*/
//create Image of size 350px x 75px
$bg = imagecreatetruecolor(350, 75);
//This will make it transparent
imagesavealpha($bg, true);
$trans_colour = imagecolorallocatealpha($bg, 0, 0, 0, 127);
imagefill($bg, 0, 0, $trans_colour);
//Text to be written
$helloworld = isset($_GET['text']) ? $_GET['text'] : "phone";
// White text
$white = imagecolorallocate($bg, 255, 255, 255);
// Grey Text
$grey = imagecolorallocate($bg, 128, 128, 128);
// Black Text
$black = imagecolorallocate($bg, 0,0,0);
$font = 'arial.ttf'; //path to font you want to use
$fontsize = 20; //size of font
//Writes text to the image using fonts using FreeType 2
imagettftext($bg, $fontsize, 0, 20, 20, $grey, $fontDir.$font, $helloworld);
//Create image
imagepng($bg);
//destroy image
ImageDestroy($bg);
?>
Thank you very much. |