SharkBait Posted November 13, 2006 Share Posted November 13, 2006 I am getting this error:The image “http://tingram.ca/test.php” cannot be displayed, because it contains errors.When I do the following:[code]<?phpHeader("Content-type: image/png");// Create image X by Y$img = imagecreatetruecolor(400, 25);//$blog_header = $entry['title'] . " [" . $entry['d'] ."]";$blog_header = " This is a test ";$white = imagecolorallocate($img, 255, 255, 255);$gray = imagecolorallocate($img, 192, 192, 192);$black = imagecolorallocate($img, 0, 0, 0);// Create rectangleimagefilledrectangle($img, 1, 1, 398, 23, $gray);$font = "OptimusPrinceps.ttf";// Image, Size, Angle, X, Y, Color, Font, Text//imagettftext($img, 10, 0, 0, 0, $white, $font, $blog_header);imagettftext($img, 8, 0, 4, 4, $white, $font, $blog_header); ImagePng($img);ImageDestroy($img);?>[/code]And I am not sure why? If I comment out the imagettftext() it works and I get a graybox with a black outline.The OptimusPrinceps font is in the same directory as this script. I use the font for another script else were so I am unsure what it is I am doing wrong. Link to comment https://forums.phpfreaks.com/topic/27127-imagetfttext-error/ Share on other sites More sharing options...
SharkBait Posted November 13, 2006 Author Share Posted November 13, 2006 Figured it out. It seems that the GD needs to be told that it needs to look for the font in the current working directory of the script so changing:[code=php:0] $font = "OptimusPrinceps.ttf"; [/code]to[code=php:0] $font = "./OptimusPrinceps.ttf"; [/code]Fixed my issue :) Link to comment https://forums.phpfreaks.com/topic/27127-imagetfttext-error/#findComment-124002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.