| вот какие дела - юзер загружает на сайт фото, а скрипт уменьшает их.
проблема - уменьшенные фотки ужасного качества.
задача - максимально улучшить качество уменьшенных фото (в т.ч. самых маленьких)...
что есть :
<?php
if (file_exists($_FILES['imagefoto']["tmp_name"]))
{
if ($userprava==3) $togetuser=$_GET['selectedusername'];
if ($userprava==1) $togetuser=$_COOKIE['login'];
if (!is_dir("img/fotos/".$togetuser)) !mkdir("img/fotos/".$togetuser, 0700);
if (!is_dir("img/fotos/".$togetuser."/!thumbs")) !mkdir("img/fotos/".$togetuser."/!thumbs", 0700);
if (!is_dir("img/fotos/".$togetuser."/!smal")) !mkdir("img/fotos/".$togetuser."/!smal", 0700);
$startimagecount=scandir("img/fotos/".$togetuser."/");
$startimagecount=count($startimagecount)-3;
$imgfilename="img/fotos/".$togetuser."/".$_POST['imgnum_ank'].".jpg";
$imgfilenamethumb="img/fotos/".$togetuser."/!thumbs/".$_POST['imgnum_ank'].".jpg";
copy($_FILES['imagefoto']["tmp_name"], $imgfilename);
// размеры маленьких картинок
$widthlittle=150;
$heigthlittle=112;
$t=getimagesize ($imgfilename) or die('Unknown type of image');
$with=$t[0];$height=$t[1];
if ($with>$height)
{
if ($with>640)
{
$rwith=640; $rheight=$rwith*($height/$with);
$widthlittle=150; $heigthlittle=$widthlittle*($height/$with);
}
else
{
$rwith=$with;
$rheight=$height;
$widthlittle=150; $heigthlittle=$widthlittle*($height/$with);
}
$img=imagecreatefromjpeg($imgfilename);
$thumb=imagecreatetruecolor($rwith,$rheight);
$thumblittle=imagecreatetruecolor($widthlittle,$heigthlittle);
$imglogo=imagecreatefrompng("img/imagelogo.png");
imagecopyresized($thumb,$img,0,0,0,0,$rwith,$rheight,$with,$height);
imagecopyresized($thumblittle,$img,0,0,0,0,$widthlittle,$heigthlittle,$with,$height);
imagecopy($thumb,$imglogo,5,$rheight-45,0,0,200,37);
}
else
{
if ($height>480)
{
$rheight=480; $rwith=$rheight/($height/$with);
$heigthlittle=112; $widthlittle=$heigthlittle/($height/$with);
}
else
{
$rwith=$with; $rheight=$height;
$heigthlittle=112; $widthlittle=$heigthlittle/($height/$with);
}
$img=imagecreatefromjpeg($imgfilename);
$thumb=imagecreatetruecolor($rwith,$rheight);
$thumblittle=imagecreatetruecolor($widthlittle,$heigthlittle);
$imglogo=imagecreatefrompng("img/imagelogo.png");
imagecopyresized($thumb,$img,0,0,0,0,$rwith,$rheight,$with,$height);
imagecopyresized($thumblittle,$img,0,0,0,0,$widthlittle,$heigthlittle,$with,$height);
imagecopy($thumb,$imglogo,5,$rheight-45,0,0,200,37);
}
imagejpeg($thumb, $imgfilename, 80);
imagejpeg($thumblittle, $imgfilenamethumb, 95);
}
?>
просьба ответить понятно, я совсем не копенгаген))
спасибо! | |