Witam
Mam taką funkcję do pomniejszania obrazka:
function resize_ratio($file, $new_w, $new_h, $save)
{
{
return FALSE;
}
$wysokosc = imagesy($file);
switch ($info['mime'])
{
case "image/gif":
$file = imagecreatefromgif($file);
break;
case "image/jpeg":
$file = imagecreatefromjpeg($file);
break;
case "image/png":
$file = imagecreatefrompng($file);
break;
}
$old_x = imageSX($file);
$old_y = imageSY($file);
if ($old_x > $old_y)
{
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y)
{
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y)
{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$th = ImageCreateTrueColor($thumb_w, $thumb_h);
@imagecopyresampled($th, $file, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);
@imagejpeg($th, $save);
@imagedestroy($file);
@imagedestroy($th);
return TRUE;
}
resize_ratio("$zdjecie", "660", "200", "$zdjecie");
Ale on zmienia dwa wymiary, a ja chcę zmienić jeden ale z zachowaniem proporcji ,czyli tym samym zmienić dwa wymiary ale nie wiem jak zachować te proporcje.
Jak to zrobić