Witam. Mam taki kod
  1. <?php
  2. Header('Content-type: image/jpeg');
  3. function resizethumb($imgName, $size)
  4. {
  5. if (!($img = imagecreatefromjpeg($imgName))) {
  6. echo 'Nie mogę otworzyć plik:'.$imgName;
  7. exit();
  8. }
  9.  
  10. $img_w = imagesx($img);
  11. $img_h = imagesy($img);
  12.  
  13. $ratio = $img_w / $img_h;
  14.  
  15. if ($ratio >1) {
  16. $new_img_w = $size;
  17. $new_img_h = ($size / $ratio);
  18.  
  19. } else {
  20. $new_img_w = ($size * $ratio);
  21. $new_img_h = $size;
  22.  
  23. }
  24.  
  25. $tempImg = imagecreatetruecolor($new_img_w, $new_img_h);
  26. imagecopyresampled($tempImg, $img, 0, 0, 0, 0, $new_img_w, $new_img_h, $img_w, $img_h);
  27.  
  28. $name = substr($imgName, 0, strlen($imgName) - 4);
  29. $name = $name."-resized.jpg";
  30. if(imagejpeg($tempImg, $name) == true){
  31. echo 'ok';
  32. }
  33.  
  34.  
  35. }
  36. resizethumb("gallery/pic.jpg", 520);
  37. ?>

Skrypt powinien zmniejszyć obraz, wyświetlić go i zapisać, ale problem polega w tym, że tego nie robi. Nie wyświetla go i nie zapisuje. Ale gdy z linii 30 w/w kodu z funkcji imagejpeg() skasuje ostatni atrybut to wtedy zmniejsza i wyświetla obraz. Dlaczego nie chce się zapisać ta miniaturkę? Proszę o pomoc