Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Problem z zmiana wielkosci zdjec
Forum PHP.pl > Forum > PHP
Hpsi
Witajcie naziwzując do porzeniego mojego tematu zwiazanego z imagecreateformjpeg. mam problem gdyż generator nonstop cos knoci w zapisywaniu strumienia oto ten kod:
  1. <?php
  2.  
  3. function zdjecie($old_path, $new_path, $width, $height)
  4.  {
  5.  $old_size = getimagesize($old_path);
  6.  
  7. if($old_size[0] <= $width && $old_size[1] <= $height)
  8. {
  9.  copy($old_path, $new_path);
  10. } // if
  11. {
  12. if($height/(($ratio = $old_size[0]/$width)) >= $width)
  13. {
  14. $ratio = $old_size[1]/$height;
  15. }   // if
  16. $new_width = $old_size[0]/$ratio;
  17. $new_height = $old_size[1]/$ratio;
  18. $old_img = imagecreatefromstring(implode('', file($old_path)));
  19. $new_img = imagecreatetruecolor($new_width, $new_height);
  20. imagecopyresampled($new_img, $old_img, 0, 0, 0, 0, $new_width, $new_height, $old_size[0], $old_size[1]);
  21. imagejpeg($new_img, $new_path);
  22. imagedestroy($old_img);
  23. imagedestroy($new_img);
  24. }// else
  25. chmod($new_path, 0777);
  26.                         
  27.  
  28. }       // function
  29.     
  30.  
  31. ?>


w którym miejscu jest bład ...
gu35t
  1. <?php
  2. function res($im_file_name){
  3. $image_attribs = getimagesize($im_file_name);
  4. $im_old = imageCreateFromJpeg($im_file_name);
  5. $th_max_width = 120;
  6. $th_max_height = 120;
  7. if($image_attribs[0]>=$image_attribs[1]){
  8.  @$ratio = ($width >= $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];
  9.  }
  10.  else{
  11. @$ratio = ($width < $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];
  12. }
  13. $th_width = $image_attribs[0] * $ratio;
  14. $th_height = $image_attribs[1] * $ratio;
  15. $im_new = imagecreatetruecolor($th_width,$th_height);
  16. $th_file_name = substr($im_file_name, 0, strlen($im_file_name)-4) . '.thumb';
  17. imageCopyResampled($im_new,$im_old,0,0,0,0,$th_width,$th_height, $image_attribs[0], $image_attribs[1]);
  18. imageJpeg($im_new,$th_file_name,80);
  19.  }
  20. ?>


pamietaj ze folder w ktorym zapisujesz zdj musi miec 777
Hpsi
dzieki ale mam pyanko w ktorym miejscu zapisujesz na dysku bo zbytnio nie chce grzebac w towim kodzie zeby nie zepsuc go
Hpsi
dziękuje ślicznie za pomoc!:)
gu35t
NMZC
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.