Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: ttftext nie generuje tekstu
Forum PHP.pl > Forum > Przedszkole
minimal2
Witajcie

mam problem z funkcją ttftext (na local'u działa ok niestety na serwerze (60free.ofv.org) nie generuje tekstu) sad.gif

Oto kod pliku generującego obrazek:
  1. <?php 
  2.  
  3. // Deklaracje zmiennych
  4. $fontDir  = 'fonts/';
  5. $fontFiles = array('verdana.ttf', 'impact.ttf', 'comic.ttf', 'arial.ttf');
  6. $string = $_GET["text"];
  7. $r = $_GET["r"];
  8. $g = $_GET["g"];
  9. $b = $_GET["b"];
  10. $width = strlen($string) * 15 + 10; 
  11. $height = 25; 
  12.  
  13. // Przesłanie nagłówków
  14. header('Content-type: image/'.$imgType); 
  15.  
  16. $img = imagecreate($width, $height); 
  17.  
  18. // Deklaracje kolorów
  19. $back = imagecolorallocate ($img, 255, 255, 255); 
  20. $font = imagecolorallocate ($img, $r, $g, $b); 
  21. $dots = imagecolorallocate ($img, rand(, 255), rand(, 255), rand(, 255)); 
  22.  
  23. // Generator plam
  24. $pts = array(); 
  25.  
  26. for($i = 0; $i < round($width / 1.5); $i++) 
  27. { 
  28.  $x = rand(0, $width); 
  29.  $y = rand(0, $height); 
  30.  
  31.  if(!in_array($x.'_'.$y, $pts)) 
  32.  { 
  33. imageellipse($img, $x, $y, rand(2, 4), rand(3, 6), $dots); 
  34. $pts[] = $x.'_'.$y; 
  35.  } 
  36.  else 
  37.  { 
  38. $i--; 
  39.  } 
  40. } 
  41.  
  42. // Generator textu
  43. for($i = 0; $i < strlen($string); $i++) 
  44. { 
  45.  imagettftext($img, rand(14, 16), rand(-10, 10), rand(3, 5) + $i * 15, 20 + rand(-3, 3), $font, $fontDir.'/'.$fontFiles[rand(0, count($fontFiles) - 1)], $string{$i}); 
  46. } 
  47.  
  48. imagecolortransparent ($img, $back);
  49.  
  50. // Wysłanie i zniszczenie obrazka
  51. imagepng($img);
  52. imagepng($img, "email.png"); 
  53. imagedestroy($img); 
  54.  
  55. ?>


Live demo: http://minimal2.ovh.org/index.php (efekt widoczny po wypełnieniu forumlarza)
vihoo
Zapuść phpinfo() na localu i serwerze.
Porównaj różnice (hint: sekcja GD) będziesz wiedział dlaczego.
minimal2
Oto wyniki (sekscja GD wyciągnięta z phpinfo):

Z serwera 60free.ofh.org:
Cytat
GD Support_____________enabled 
GD Version  bundled______(2.0.28 compatible) 
FreeType Support________enabled 
FreeType Linkage________with TTF library 
FreeType Version________1.5 
T1Lib Support___________enabled 
GIF Read Support________enabled 
GIF Create Support_______enabled 
JPG Support_____________enabled 
PNG Support____________enabled 
WBMP Support__________enabled 
XBM Support___________enabled


Z localhosta:
Cytat
GD Support____________enabled 
GD Version  bundled_____(2.0.28 compatible) 
FreeType Support_______enabled 
FreeType Linkage_______with freetype
FreeType Version_______2.1.9
GIF Read Support_______enabled 
GIF Create Support______enabled 
JPG Support____________enabled 
PNG Support___________enabled 
WBMP Support_________enabled 
XBM Support__________enabled


Tylko dwie różnice... czy one coś znaczą?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.