Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Generowanie tekstu na obrazie KRZAKI
R_D_U
post
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 1
Dołączył: 21.01.2012

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


WItam, mam problem z generownaniem tekstu na obrazie mianowicie gdy kod wygląda tak:
  1. <?
  2.  
  3. // Otwieramy plik graficzny
  4. $rysunek = ImageCreateFromPng("6.png");
  5.  
  6. // Definicje kolorów jako składowe RGB
  7. $bialy = ImageColorAllocate($rysunek, 255, 255, 255);
  8. $nieb = ImageColorAllocate($rysunek, 0, 255, 255);
  9.  
  10. // Lokacja łańcucha i jego wartość
  11. ImageString($rysunek, 50, 100, 60, "tekst1", $bialy);
  12. ImageString($rysunek, 5, 180, 20, "tekst2", $nieb);
  13.  
  14. // Stworzenie wynikowej grafiki
  15. header("Content-type: image/png");
  16. ImagePng($rysunek);
  17.  
  18.  
  19. ?>

To wszystko jest okej lecz gdy dodam inny jaki kolwiek kod np łącznie z bazą danych to wywali mi kod obrazka taki jak bym go otworzył w notatniku albo w czyms podobnym. Jak temu zapobiec??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
R_D_U
post
Post #2





Grupa: Zarejestrowani
Postów: 28
Pomógł: 1
Dołączył: 21.01.2012

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


Zmieniłem na takie coś żeby z GET pobierać narazie ale nie moge nic innego dodać i tego do czegoś inneco nawet include'm:
  1. <?php
  2.  
  3.  
  4. header('Content-type: image/png');
  5.  
  6. // Create the image
  7. $im = imagecreatefrompng('6.png');
  8. imageAlphaBlending($im, true);
  9. imageSaveAlpha($im, true);
  10.  
  11. // Create some colors
  12. $white = imagecolorallocate($im, 255, 255, 255);
  13. $grey = imagecolorallocate($im, 128, 128, 128);
  14. $black = imagecolorallocate($im, 0, 0, 0);
  15. $red = imagecolorallocate($im, 176, 0, 4);
  16.  
  17.  
  18. // The text to draw
  19. $text[0] = 'Sygnaturka test 1';
  20. $text[1] = $_GET['nick'];
  21. $text[2] = $_GET["level"];
  22. $text[3] = $_GET["kasa"];
  23.  
  24. // Replace path by your own font path
  25. $font = 'Harabara.ttf';
  26.  
  27. // Add the text
  28. imagettftext($im, 18, 0, 60, 32, $red, $font, $text[0]);
  29. imagettftext($im, 16, 0, 240, 32, $white, $font, $text[1]);
  30. imagettftext($im, 16, 0, 180, 56, $white, $font, $text[2]);
  31. imagettftext($im, 16, 0, 180, 80, $white, $font, $text[3]);
  32.  
  33. // Using imagepng() results in clearer text compared with imagejpeg()
  34. imagepng($im);
  35. imagedestroy($im);
  36.  
  37. ?>
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: 14.10.2025 - 09:46