Image Creation Problems (Displaying Text)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
4d5e6f
Forum Newbie
Posts: 2
Joined: Mon Dec 06, 2004 5:43 pm

Image Creation Problems (Displaying Text)

Post 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);
?>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
4d5e6f
Forum Newbie
Posts: 2
Joined: Mon Dec 06, 2004 5:43 pm

Post 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.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
Post Reply