imagefttext working locally, but error on prodserver

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
kae
Forum Newbie
Posts: 1
Joined: Thu Jul 23, 2009 4:23 am

imagefttext working locally, but error on prodserver

Post by kae »

Hi.
I'm pretty new to PHP and are trying to make a script that generates a png from a textstring using imagefttext and a custom font in the same folder as the script. Everything works locally, but when I try it on the prodserver (Mac) I get Thread 0 Crashed in my logs.
I see in php info that gd-imgstrttf & gd-native-ttf are enabled on my local server, but not on the prodserver. I've tried to google som info about those, but find very little (except for how to recompile php to enable them).

Any help appreciated :-)

My code:

Code: Select all

<?php
    header('Content-type: image/png');
    //  putenv('GDfontPATH=' . realpath('.'));
    $font_file = 'categoryfont_bd.ttf';
    is_readable($font_file) or die('font file cannot be accessed !');
    $im = imagecreatetruecolor(500, 100);
    $backColor = imagecolorallocate($im, 0xFF, 0xaf, 0xff);
    $textColor = imagecolorallocate($im, 0x34, 0x77, 0x30);
 
    imagefilledrectangle($im, 0, 0, 500, 99, $backColor);
 
    imagefttext($im, 40 0, 10, 50, $textColor, $font_file, "Test");
 
    imagepng($im, 'text.jpg', 100);
    imagedestroy($im);
?>
Post Reply