Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Biblioteka GD
r_mag13
post
Post #1





Grupa: Zarejestrowani
Postów: 26
Pomógł: 1
Dołączył: 3.03.2009

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


Witam!

Używam serwera: WampServer Version 2.0 (LINK).

Mam problem z dynamicznym generowaniem grafiki w PHP.
Takie cuś znalazłem na PHP.net (LINK) :
Cytat
In Windows, you'll include the GD2 DLL php_gd2.dll as an extension in php.ini. The GD1 DLL php_gd.dll was removed in PHP 4.3.2. Also note that the preferred truecolor image functions, such as imagecreatetruecolor(), require GD2.


Więc otworzyłem plik php.ini i znalazłem tam coś takiego

...
; Windows Extensions...(potem kilka tych *.dll)
extension=php_gd2.dll
...

Ponadto w WampSerwer jest coś takiego:
(IMG:http://img111.imageshack.us/img111/8435/wampgd.th.jpg)

I wreszcie moje pytanie: Czy ja o czymś zapomniałem jeśli chodzi o dynamiczne generowanie grafiki? Bo przeglądałem tutoriale na internecie i żaden mi nie chciał poprawnie działać. Może trzeba dograć jakieś jeszcze biblioteki, rozszerzenia albo co?

Oto przykład z php.net (który mi nie działał (IMG:http://forum.php.pl/style_emoticons/default/sadsmiley02.gif) ):
Kod
<?php
header("Content-type: image/png");
$string = $_GET['text'];
$im     = imagecreatefrompng("images/button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px     = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
?>


Bardzo proszę o pomoc i z góry dziękuje za pomoc.

Ten post edytował r_mag13 3.03.2009, 09:55:49
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
wookieb
post
Post #2





Grupa: Moderatorzy
Postów: 8 989
Pomógł: 1550
Dołączył: 8.08.2008
Skąd: Słupsk/Gdańsk




Zacznijmy od tego czy gd sie poprawnie uruchomil.
Włącz porządne raportowanie błędów (E_ALL) i potem
Kod
var_dump(function_exists('gd_info'));

Jeżeli bedzie false tzn ze gd nie uruchomiło sie poprawnie.
Jeżeli true to spróbuj zrobić test z tym kodem.
  1. <?php
  2. $values = array(
  3.            40,  50,  // Point 1 (x, y)
  4.            20,  240, // Point 2 (x, y)
  5.            60,  60,  // Point 3 (x, y)
  6.            240, 20,  // Point 4 (x, y)
  7.            50,  40,  // Point 5 (x, y)
  8.            10,  10   // Point 6 (x, y)
  9.            );
  10.  
  11. // create image
  12. $image = imagecreatetruecolor(250, 250);
  13.  
  14. // allocate colors
  15. $bg   = imagecolorallocate($image, 200, 200, 200);
  16. $blue = imagecolorallocate($image, 0, 0, 255);
  17.  
  18. // fill the background
  19. imagefilledrectangle($image, 0, 0, 249, 249, $bg);
  20.  
  21. // draw a polygon
  22. imagefilledpolygon($image, $values, 6, $blue);
  23.  
  24. // flush image
  25. header('Content-type: image/png');
  26. imagepng($image);
  27. imagedestroy($image);
  28. ?>


Ten post edytował wookieb 3.03.2009, 10:55:07
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: 28.12.2025 - 22:24