Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Jak użyć funkcji do tworzenia miniatur
honytowk
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 3
Dołączył: 11.09.2008
Skąd: Gliwice

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


Witam, mógł by mi ktoś wytłumaczyć jak użyć tej funkcji do tworzenia miniatur gd?

  1. function createthumbnail($filetype, $origfile, $thumbfile, $new_w, $new_h) {
  2.  
  3. global $settings;
  4.  
  5. if ($filetype == 1) { $origimage = imagecreatefromgif($origfile); }
  6. elseif ($filetype == 2) { $origimage = imagecreatefromjpeg($origfile); }
  7. elseif ($filetype == 3) { $origimage = imagecreatefrompng($origfile); }
  8.  
  9. $old_x = imagesx($origimage);
  10. $old_y = imagesy($origimage);
  11.  
  12. if ($old_x > $new_w || $old_y > $new_h) {
  13. if ($old_x < $old_y) {
  14. $thumb_w = round(($old_x * $new_h) / $old_y);
  15. $thumb_h = $new_h;
  16. } elseif ($old_x > $old_y) {
  17. $thumb_w = $new_w;
  18. $thumb_h = round(($old_y * $new_w) / $old_x);
  19. } else {
  20. $thumb_w = $new_w;
  21. $thumb_h = $new_h;
  22. }
  23. } else {
  24. $thumb_w = $old_x;
  25. $thumb_h = $old_y;
  26. }
  27.  
  28. if ($settings['thumb_compression'] == "gd1") {
  29. $thumbimage = imagecreate($thumb_w,$thumb_h);
  30. $result = imagecopyresized($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
  31. } else {
  32. $thumbimage = imagecreatetruecolor($thumb_w,$thumb_h);
  33. $result = imagecopyresampled($thumbimage, $origimage, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
  34. }
  35.  
  36. touch($thumbfile);
  37.  
  38. if ($filetype == 1) { imagegif($thumbimage, $thumbfile); }
  39. elseif ($filetype == 2) { imagejpeg($thumbimage, $thumbfile); }
  40. elseif ($filetype == 3) { imagepng($thumbimage, $thumbfile); }
  41. }


użyłem jej tak:
  1. <?php
  2. require_once "maincore.php";
  3. require_once INCLUDES."photo_functions_include.php";
  4.  
  5. createthumbnail("jpg", "images/photoalbum/useralbum_48/a", "images/photoalbum/useralbum_48/a_t.jpg", "100", "100");
  6.  
  7.  
  8. ?>


i jak wejdę w plik z pozycji przeglądarki to wyskakują błędy a funkcja w 100% działa
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this 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 - 15:58