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?
<?
if(isset($_FILES['plik']) && $_FILES['plik']['tmp_name']!="") {
list
($www, $hh, $type, $attr) = getimagesize($_FILES['plik']['tmp_name']); if($type!=2)
{
echo"proszę uploadować tylko pliki JPG!"; }
$_POST['towkod']=str_replace(" ", "_", $_POST['towkod']); $filename = 'foto/'.$_POST['towkod'].'.jpg';
{
////////////////// 1 ////////////////////////////
$width = 40;
$height = 40;
if ($width && ($width_orig < $height_orig))
$width = ($height / $height_orig) * $width_orig;
else
$height = ($width / $width_orig) * $height_orig;
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($thumb, "foto/m_".$_POST['towkod'].".jpg", 100);
////////////////// 2 ////////////////////////////
$width = 195;
$height = 195;
if ($width && ($width_orig < $height_orig))
$width = ($height / $height_orig) * $width_orig;
else
$height = ($width / $width_orig) * $height_orig;
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($thumb, "foto/s_".$_POST['towkod'].".jpg", 100);
////////////////// 3 ////////////////////////////
$width = 600;
$height = 600;
if ($width && ($width_orig < $height_orig))
$width = ($height / $height_orig) * $width_orig;
else
$height = ($width / $width_orig) * $height_orig;
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($thumb, $filename, 100);
/////////////////////////////////////////////////
}
}
?>