With the success of http://dig.knight47.com/ I decided to try another, similar script here:

http://dig.knight47.com/toi/

This is the error I'm getting from generated images.

<br />
<b>Warning</b>:  imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Could not find/open font in <b>/home/.morrison/dig/dig.knight47.com/toi/timg.php</b> on line <b>19</b><br />
<br />
<b>Warning</b>:  imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Could not find/open font in <b>/home/.morrison/dig/dig.knight47.com/toi/timg.php</b> on line <b>20</b><br />

Here is the code

<?php
header("Content-type: image/png");
$w = $_GET['w'];
$h = $_GET['h'];
$r = $_GET['r'];
$g = $_GET['g'];
$b = $_GET['b'];
$tr = $_GET['tr'];
$tg = $_GET['tg'];
$tb = $_GET['tb'];
$cfont = $_GET['font'];
$string = $_GET['text'];
$font = $cfont.'.tff';
$im = imagecreatetruecolor($w, $h);
$background = imagecolorallocate($im, $r, $g, $b); //RGB (Red Green Blue)
$shadow = imagecolorallocate($im, 128, 128, 128);
$text = imagecolorallocate($im, $tr, $tg, $tb); //RGB for text
imagefilledrectangle($im, 0, 0, ($w - 1), ($h - 1), $background);
imagettftext($im, 20, 0, 11, 26, $shadow, $font, $string); //Shadow
imagettftext($im, 20, 0, 10, 25, $text, $font, $string); //Text
imagepng($im);
imagedestroy($im);
?>

    Well, the issue is that it can't find the font. Probably because there is no such font named "Chiller" or "Arial" .tff it's TTF.

    Also, do some checking on your script!! Sanitize the input, cast it to integers or strings etc. But don't just automatically assume that users will input completely valid data!!

    Hope that helps.

      bpat1434 wrote:

      .tff it's TTF.

      oops :o
      Thanks! 🙂

        Write a Reply...