Jump to content

dynamic image generator


desithugg

Recommended Posts

Umm im trying to create a dynamic signature with php ive never done this before so i was looking for some examples i tried a couple like the one below and i keep getting the same error
[quote]
The image “http://pi.x3teamz.net/members/pic.php” cannot be displayed, because it contains errors.
[/quote]
[code]
<?php
  Header("Content-type: image/gif");
  if(!isset($s)) $s=11;
  $text = "saad";
  $size = imagettfbbox($s,0,"/fonts/TIMES.TTF",$text);
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=9;
  $ypad=9;
  $im = imagecreate($dx+$xpad,$dy+$ypad);
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
  $black = ImageColorAllocate($im, 0,0,0);
  $white = ImageColorAllocate($im, 255,255,255);
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "/fonts/TIMES.TTF", $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "/fonts/TIMES.TTF", $text);
  ImageGif($im);
  ImageDestroy($im);
?>
[/code]
yes i do have a fonts folder and a file called TIMES.TTF
Link to comment
https://forums.phpfreaks.com/topic/20331-dynamic-image-generator/
Share on other sites

umm nope doesnt work
[code]
<?php
  Header("Content-type: image/gif");
  if(!isset($s)) $s=11;
  $text = "saad";
  $size = imagettfbbox($s,0,"http://pi.x3teamz.net/fonts/TIMES.TTF",$text);
  $dx = abs($size[2]-$size[0]);
  $dy = abs($size[5]-$size[3]);
  $xpad=9;
  $ypad=9;
  $im = imagecreate($dx+$xpad,$dy+$ypad);
  $blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
  $black = ImageColorAllocate($im, 0,0,0);
  $white = ImageColorAllocate($im, 255,255,255);
  ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
  ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
  ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "http://pi.x3teamz.net/fonts/TIMES.TTF", $text);
  ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "http://pi.x3teamz.net/fonts/TIMES.TTF", $text);
  ImageGif($im);
  ImageDestroy($im);
?>
[/code]
OK, check the version of PHP/GD you're using.

GIF write support wasn't included as default in later versions, it was replaced by PNP, but some servers still have it.

From the PHP Documentation:
[color=red][i]Only supported in GD versions older than gd-1.6 and newer than gd-2.0.28. Read-only  GIF support is available with PHP 4.3.0 and the bundled GD-library. Write support is avaliable since PHP 4.3.9 and PHP 5.0.1.[/i][/color]

You can find this out my using phpinfo()

Regards
Rich

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.