Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Postrzępione miniatury
patrykt
post 26.04.2006, 12:33:52
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 0
Dołączył: 3.12.2005

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


mam prosty skrypt do robienia trzech różnej wielkości miniatur z jednego, uploadowanego przez nas. jednakże wynikowe obrazki mają ostre, postrzępione brzegi (http://lema.dtl.pl/foto/s_AC_25.jpg). jakieś pomysły?

  1. <? 
  2. if(isset($_FILES['plik']) && $_FILES['plik']['tmp_name']!="") 
  3. { 
  4. list($www, $hh, $type, $attr) = getimagesize($_FILES['plik']['tmp_name']); 
  5. if($type!=2) 
  6. { 
  7. echo"proszę uploadować tylko pliki JPG!"; 
  8. exit; 
  9. } 
  10.  
  11. $_POST['towkod']=str_replace(" ", "_", $_POST['towkod']); 
  12. $filename = 'foto/'.$_POST['towkod'].'.jpg'; 
  13.  
  14. if(move_uploaded_file($_FILES['plik']['tmp_name'], $filename)) 
  15. { 
  16.  
  17. list($width_orig, $height_orig) = getimagesize($filename); 
  18.  
  19. ////////////////// 1 //////////////////////////// 
  20. $width = 40; 
  21. $height = 40; 
  22. if ($width && ($width_orig < $height_orig)) 
  23. $width = ($height / $height_orig) * $width_orig; 
  24. else 
  25. $height = ($width / $width_orig) * $height_orig; 
  26. $thumb = imagecreatetruecolor($width, $height); 
  27. $source = imagecreatefromjpeg($filename); 
  28. imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); 
  29. imagejpeg($thumb, "foto/m_".$_POST['towkod'].".jpg", 100); 
  30. ////////////////// 2 //////////////////////////// 
  31. $width = 195; 
  32. $height = 195; 
  33. if ($width && ($width_orig < $height_orig)) 
  34. $width = ($height / $height_orig) * $width_orig; 
  35. else 
  36. $height = ($width / $width_orig) * $height_orig; 
  37. $thumb = imagecreatetruecolor($width, $height); 
  38. $source = imagecreatefromjpeg($filename); 
  39. imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); 
  40. imagejpeg($thumb, "foto/s_".$_POST['towkod'].".jpg", 100); 
  41. ////////////////// 3 //////////////////////////// 
  42. $width = 600; 
  43. $height = 600; 
  44. if ($width && ($width_orig < $height_orig)) 
  45. $width = ($height / $height_orig) * $width_orig; 
  46. else 
  47. $height = ($width / $width_orig) * $height_orig; 
  48. $thumb = imagecreatetruecolor($width, $height); 
  49. $source = imagecreatefromjpeg($filename); 
  50. imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); 
  51. imagejpeg($thumb, $filename, 100); 
  52. ///////////////////////////////////////////////// 
  53. } 
  54. } 
  55. ?>
Go to the top of the page
+Quote Post

Posty w temacie
- patrykt   Postrzępione miniatury   26.04.2006, 12:33:52
- - Jojo   Zamiast imagecopyresized" title="Zobacz w manualu ...   26.04.2006, 12:36:29
- - patrykt   <ukłony>   26.04.2006, 12:42:19


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 Wersja Lo-Fi Aktualny czas: 19.07.2025 - 12:46