PDA

View Full Version : Image-creation is failing...


SYP}{ER
11-11-2002, 09:40 PM
<?
header("content-type: image/jpeg");
if(isset($string)) {
$text_height = 18;
$image_height = 26;
$tfont = "deftone.ttf";
$string = stripslashes($string);
$tst = ImageTTFBBox($text_height,0,$tfont,$string);
$widtxt = ($tst[2]-$tst[0]);
$heitxt = ($tst[5]-$tst[3]);
$btnwid = $widtxt+12;
$thebtn = ImageCreate($btnwid,$image_height);
$blk = ImageColorAllocate($thebtn,0,0,0);
ImageFill($thebtn,0,0,$blk);
$colour = ImageColorAllocate($thebtn,255,204,0);
$txtx = 6;
$txty = $text_height;
ImageTTFText ($thebtn,$text_height,0,$txtx,$txty,$colour,$tfont,$string);
ImagePNG($thebtn);
ImageDestroy($thebtn);
}
else {}
?>

See it live: http://sean.aaron-wright.com/images/titlemaker.php?string=Home

The error:
Could not find/open font in /home/virtual/site24/fst/var/www/html/images/titlemaker.php on line 8 and 18

Now the font is in the same folder as the script (images/) and is CHMODed to 777 (full permissions). What's goin' on?

Thanks :)

SYP}{ER
11-12-2002, 09:46 PM
No one? :(

Ökii
11-13-2002, 11:55 AM
if the problem is really based in accessing the font, check case-sensitivity (foldername, filename AND extension).

perhaps try referencing it from root.

Also note: you send a jpeg header and output a png

SYP}{ER
11-13-2002, 08:31 PM
Oh crap. Dude you're right about the header... That must be it!

I'll change that :S *smacks head*

SYP}{ER
11-13-2002, 08:34 PM
Dangit. Didn't fix it :(

Case has been checked and double checked. Could TrueType or whatever it's called be looking in a preset fonts dir? If so, where would I find out where it's looking? My admin is baffled too :S

Ökii
11-14-2002, 09:38 AM
Is freetype (or whatever ttf submodule that they use) working / configured properly?

*****
There are actually only about 4 or 5 fonts that force truetype to look in the servers font folder. I don't believe you can reference them by name either, you have to use a numeric. ****** ignore that, that only works for ImageString :rolleyes:

the online manual states that (for ttfbbox and ttftext),

Depending on which version of the GD library that PHP is using, when fontfile does not begin with a leading '/', '.ttf' will be appended to the filename and the the library will attempt to search for that filename along a library-defined font path.

Perchance that helps. If you are still having probs later, msn me and I'll try the script on one of my hosts.

SYP}{ER
11-15-2002, 12:42 AM
Still got probs :(

I'll try to catch you on MSN then. It didn't work on my old host either :S It works on my comp though!

Ökii
11-15-2002, 10:58 AM
In your phpinfo() return, does it say

FreeType Support --------- enabled
FreeType Linkage --------- with freetype

or

FreeType Support --------- enabled
FreeType Linkage --------- with TTF library


I tried the scriptlet on a couple of servers (tried a very basic text write as well) and could only get it to work on the server stating with TTF library.
I also know the working server has GD1.8.4 running - all I know about the non ttf able one is that it's GD1.6.2 or above.

Hey - you could try pestering your host to try out GD2.0.4 (antialiased text on truecolour pngs ;))

SYP}{ER
11-15-2002, 01:00 PM
"with freetype"

I'll nag about GD2.0.4 :P