Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Generowanie obrazka zamiast tekstu
podol
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

Ostrzeżenie: (0%)
-----


mam taki skrypt:

  1. <?
  2.  
  3. function getImageWithText($text, $font, $size)
  4. {
  5. $arr = imagettfbbox($size, o, $font, $text);
  6. $width = abs(arr[2] - $arr[0]) + 5;
  7. $height = abs($arr[1] - $arr[7]) + 1;
  8. $img = imagecreatetruecolor($width, $height);
  9. $white = imagecolorallocate($img, 255, 255, 255);
  10. $black = imagecolorallocate($img, 0, 0, 0);
  11.  
  12. imagefill($img, o, o, $white);
  13. imagegettftext($img, $size, 0, 0, $height - 5, $black, $font, $text);
  14.  
  15. return $img;
  16.  
  17. }
  18.  
  19. $img = getImageWithText("napis", "arial.ttf", 30);
  20. imagejpeg($img);
  21. imagedestroy($img);
  22.  
  23. ?>


Niestety pojawia się błąd:

Kod
Parse error: syntax error, unexpected '[' in C:\Program Files\WebServ\httpd\skrypt.php on line 6


Może ktoś mi pomoże

Ten post edytował podol 27.03.2006, 18:07:01
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
podol
post
Post #2





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 12.07.2005
Skąd: Starogard Gdański

Ostrzeżenie: (0%)
-----


  1. <?php
  2. // Set the content-type
  3. header("Content-type: image/png");
  4.  
  5. // Create the image
  6. $im = imagecreate(400, 30);
  7.  
  8. // Create some colors
  9. $white = imagecolorallocate($im, 255, 255, 255);
  10. $grey = imagecolorallocate($im, 128, 128, 128);
  11. $black = imagecolorallocate($im, 0, 0, 0);
  12.  
  13. // The text to draw
  14. $text = 'Testing...';
  15. // Replace path by your own font path
  16. $font = 'arial.ttf';
  17.  
  18. // Add some shadow to the text
  19. imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
  20.  
  21. // Add the text
  22. imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
  23.  
  24. // Using imagepng() results in clearer text compared with imagejpeg()
  25. imagepng($im);
  26. imagedestroy($im);
  27. ?>


Uzylem tego wszystko dziala jak nalezy. Dzieki! (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował podol 27.03.2006, 18:45:44
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 16:10