Вы пытаетесь сделать что-то подобное?
$targetsize = $x = $y = 180;
list($width, $height) = getimagesize($file);
if($width > $targetsize || $height > $targetsize) {
$aspect = $width / $height;
if($aspect < 1) $x *= $aspect; // portrait
else $y /= $aspect; // landscape
resizeImageFunctionHere($file, $x, $y);
}
Но если вы всегда хотите ширину 180 независимо от того, портретная фотография или нет:
$targetwidth = $x = $y = 180;
list($width, $height) = getimagesize($file);
if($width > $targetsize) {
$aspect = $width / $height;
$y *= $aspect;
resizeImageFunctionHere($file, $x, $y);
}