Jump to content


Photo

dynamic image generator


  • Please log in to reply
5 replies to this topic

#1 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 10 September 2006 - 11:36 PM

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

The image “http://pi.x3teamz.net/members/pic.php” cannot be displayed, because it contains errors.

<?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);
?>
yes i do have a fonts folder and a file called TIMES.TTF

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 September 2006 - 11:58 PM

Does it work if you specify absolute path to your font file instead of relative.

The only error I found was with font file path - I had to substitute my own - but it worked OK then
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 11 September 2006 - 12:03 AM

umm nope doesnt work
<?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);
?>


#4 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 11 September 2006 - 12:05 AM

umm i think the problem is with my host i just tried some other host and it works

#5 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 11 September 2006 - 12:07 AM

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:
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.

You can find this out my using phpinfo()

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#6 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 11 September 2006 - 12:12 AM

i tried png also





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users