Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Closed TopicStart new topic
> Zapisywanie zdjęcia, czy jest taka funkcja?
eko_moto
post
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 8.01.2006
Skąd: z Wawy

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


Napisałem taki kod php do rysowania:

  1. <?php
  2.  
  3. $fontDir = 'fonts';
  4. $font = "MiniForma2.ttf";
  5. $length = 6;
  6. $img = imagecreate(100,25);
  7. $fontColor = imagecolorallocate($img,11,11,11);
  8. $bg = imagecolorallocate($img,240,240,240);
  9. imagefill($img,0,0,$bg);
  10.  
  11.  $string = substr(md5(uniqid(rand(1,9)))), 0, $length);
  12.  
  13.  for ($i = 0; $i < $length; $i++) {
  14. imagettftext($img, 12, rand(2,10), rand(1,5)+$i*15, 20+rand(-3,3), $fontColor, $fontDir.'/'.$font, $string{$i});
  15. }
  16.  
  17. header('Content-type: image/gif');
  18. imagegif($img);
  19.  
  20. ?>


Tutaj jest próbka wygenerowanego obrazu...


I teraz pytanie...
Czy można zapisać do pliku .gif wygenerowany obraz? Czy jest do tego jakaś konkretna funkcja?

Ten post edytował eko_moto 29.01.2006, 20:16:18


--------------------
<span style="font-style: italic;">"Kto nie dąży do rzeczy niemożliwych, nigdy ich nie osiągnie."
<span style="font-weight: bold;">Heraklit</span></
Go to the top of the page
+Quote Post
angel2953
post
Post #2





Grupa: Zarejestrowani
Postów: 199
Pomógł: 5
Dołączył: 8.07.2004
Skąd: gdynia

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


imagegif


--------------------
Sygnaturkę ukradli
Go to the top of the page
+Quote Post
tiraeth
post
Post #3





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


Jako drugi parametr funkcji imagegif należy podać ścieżkę z nazwą pliku, pod którą php ma zapisać obraz.

  1. <?php
  2.  
  3. $fontDir = 'fonts';
  4. $font = "MiniForma2.ttf";
  5. $length = 6;
  6. $img = imagecreate(100,25);
  7. $fontColor = imagecolorallocate($img,11,11,11);
  8. $bg = imagecolorallocate($img,240,240,240);
  9. imagefill($img,0,0,$bg);
  10.  
  11. $string = substr(md5(uniqid(rand(1,9)))), 0, $length);
  12.  
  13. for ($i = 0; $i < $length; $i++)
  14. {
  15. imagettftext($img, 12, rand(2,10), rand(1,5)+$i*15, 20+rand(-3,3), $fontColor, $fontDir.'/'.$font, $string{$i});
  16. }
  17.  
  18. header('Content-type: image/gif');
  19. imagegif($img, "obrazek.gif");
  20.  
  21. ?>
Go to the top of the page
+Quote Post

Closed TopicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 10:18