PHPJack77 Posted June 6, 2007 Share Posted June 6, 2007 I've been working with the GD 2 library for a couple of days now and keep running into problem after problem.First of all, on my test server, I am able to view the code below, however when I move it to my server, the text does not appear. I checked my server settings with gd_info() and my server fully supports GD 2. I also made sure that the gd .dll file was not commented out in the php.ini.Does anyone have any idea what the problem might be.Here is the code: <?php// Set the content-typeheader("Content-type: image/png");// Create the image$im = imagecreatetruecolor(400, 30); #Image width / Image height// Create some colors$white = imagecolorallocate($im, 255, 255, 255);$grey = imagecolorallocate($im, 128, 128, 128);$black = imagecolorallocate($im, 0, 0, 0);imagefilledrectangle($im, 0, 0, 399, 29, $white);// The text to draw$text = 'This is only partially working!';// Font to use$font = 'font.ttf';// Add some shadow to the textimagettftext($im, 20, 0, 11, 21, $grey, $font, $text);// Add the textimagettftext($im, 20, 0, 10, 20, $black, $font, $text);// Using imagepng() results in clearer text compared with imagejpeg()imagepng($im);imagedestroy($im);?> Link to comment Share on other sites More sharing options...
Mr_CHISOL Posted June 6, 2007 Share Posted June 6, 2007 I think the problem lies with the font, make sure the font can be used on the server (that GD can find it and that it's readeble for the "serveruser" [www-data or something like that]). Also make shure that the file isn't currupted. If the font files is placed in a dir that can be reached "from the web" (somewhere under the serverroot etc), try to open it in your browser (http://server/font.ttf or something..), see if you get any error messages etc. Link to comment Share on other sites More sharing options...
Anders Moen Posted June 6, 2007 Share Posted June 6, 2007 Have you uploaded font.ttf to your server or some other font? If another font, you have to change this line: // Font to use$font = 'font.ttf'; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.