Page 1 of 1

Image Creation Problems (Displaying Text)

Posted: Mon Dec 06, 2004 5:50 pm
by 4d5e6f
I'm working on a script for my site to display a random quote from my database (I know how to do that - I'll implement once I get this working). However, my code doesn't want to show the text! My font url is correct (you can check for yourself). What's wrong with my code? http://www.4d5e6f.com/randomquote.php

Code: Select all

<?php
  header("Content-type: image/gif");
  $quote = "4d5e6f.com - a god within itself";
  $im = imagecreate(400,32);
  $background = imagecolorallocate($im,255,255,255);
  $grey = imagecolorallocate($im,100,100,100);
  $black = imagecolorallocate($im,0,0,0);
  imagerectangle($im,0,0,399,31,$black);
  imagettftext($im,12,0,0,0,$black,"http://www.4d5e6f.com/Vera.ttf",$quote);
  imagegif($im);
  imagedestroy($im);
?>

Posted: Mon Dec 06, 2004 5:55 pm
by pickle
My first question would be: Why are you putting the quote in an image? That's tons of overhead that isn't necessary. Why not just dump the data right from the db?

Posted: Mon Dec 06, 2004 5:56 pm
by 4d5e6f
imagegif makes it a GIF. I want it to make it an image so I can use it on forums and such, plus it's cool, as I can add effects to it later on.

*edit*
Is it possible that my hosting doesn't let me use the text drawing functions? If so, why would the other things like drawing boxes work?

*edit2*
Not even the thing at http://us2.php.net/manual/en/function.imagettftext.php works.

Posted: Mon Dec 06, 2004 10:30 pm
by kettle_drum
Try to put the font file into the local directory and then call it as a local file instead of a remote one.