Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Obcinanie obrazka
Kamil9132
post
Post #1





Grupa: Zarejestrowani
Postów: 210
Pomógł: 0
Dołączył: 7.11.2010

Ostrzeżenie: (10%)
X----


Witam
Mam taką funkcje ,która obcina i zapisuje obrazek:
  1. function resize_ratio($file, $new_w, $new_h, $save)
  2. {
  3. if (!is_readable($file))
  4. {
  5. return FALSE;
  6. }
  7.  
  8. $info = @getimagesize($file);
  9. switch ($info['mime'])
  10. {
  11. case "image/gif":
  12. $file = imagecreatefromgif($file);
  13. break;
  14. case "image/jpeg":
  15. $file = imagecreatefromjpeg($file);
  16. break;
  17. case "image/png":
  18. $file = imagecreatefrompng($file);
  19. break;
  20. }
  21.  
  22. $old_x = imageSX($file);
  23. $old_y = imageSY($file);
  24.  
  25. if ($old_x > $old_y)
  26. {
  27. $thumb_w=$new_w;
  28. $thumb_h=$old_y*($new_h/$old_x);
  29. }
  30.  
  31. if ($old_x < $old_y)
  32. {
  33. $thumb_w=$old_x*($new_w/$old_y);
  34. $thumb_h=$new_h;
  35. }
  36.  
  37. if ($old_x == $old_y)
  38. {
  39. $thumb_w=$new_w;
  40. $thumb_h=$new_h;
  41. }
  42.  
  43. $th = ImageCreateTrueColor($thumb_w, $thumb_h);
  44. @imagecopyresampled($th, $file, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
  45. @imagejpeg($th, $save);
  46. @imagedestroy($file);
  47. @imagedestroy($th);
  48. return TRUE;
  49. }
  50.  
  51. /* Uzycie */
  52. resize_ratio("upload/$plik_nazwa", "150", "150", "upload/$plik_nazwa");


Nie jestem autorem tej funkcji więc nie wiem jak zrobić żeby zamiast zapisywać obrazek go po prostu wyświetlała.

1.Jak zrobić żeby ta funkcja wyświetlała obrazek ,a nie go zapisywała questionmark.gif

2.Jak sprawdzić rozdzielczość przeglądarki questionmark.gif
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: 22.08.2025 - 03:15