Mam taki kod:

  1. <?php
  2.  
  3. function makeThumb ($fileUrl, $moveDir, $fileSize){
  4.  
  5. list($width, $height) = getimagesize($fileUrl);
  6.  
  7. if($width > $height){
  8. $max = $width;
  9. $min = $height;
  10. }
  11. if($width <= $height){
  12. $max = $height;
  13. $min = $width;
  14. }
  15.  
  16. $rate = $max/$fileSize;
  17. $final_x = $width/$rate;
  18. $final_y = $height/$rate;
  19.  
  20. if($final_x > $width) {
  21. $final_x = $width;
  22. $final_y = $height;
  23. }
  24.  
  25. $final_x = ceil($final_x);
  26. $final_y = ceil($final_y);
  27.  
  28. $image_p = imagecreatetruecolor($final_x, $final_y);
  29. $image = imagecreatefromjpeg($fileUrl);
  30. $finalImg = imagecopyresampled($image_p, $image, 0, 0, 0, 0, $final_x, $final_y, $width, $height);
  31.  
  32. imagejpeg($finalImg, $moveDir, 70);
  33.  
  34. imagedestroy($image_p);
  35. imagedestroy($image);
  36.  }
  37.  
  38. makeThumb('../tmp/0000001.jpg', './images/', 640);
  39. ?>


Ma on za zadanie przekonwertowanie obrazka z tmp/0000001.jpg do images/0000001.jpg o mniejszych wymiarach.

Układ plików wygląda następująco:

Kod
+ admin
   - index.php
+ images
+ tmp
   - 0000001.jpg


A interpreter php zwraca:

Kod
Warning: imagejpeg(): supplied argument is not a valid Image resource in /admin/index.php on line 33


Co tu nie gra i jak to poprawić?