Yes that should fix it the way you have programmed it, But I noticed that you are not using the $CONFIG[‘thumb_use’] to calculate the $ratio – this can give you wrong sizes for thumbs in portrait mode…. use something like
//Calculate the thumbnail dimensions
if ($CONFIG['thumb_use'] == 'ht') {
$ratio = $height / $CONFIG['thumb_width'] ;
} elseif ($CONFIG['thumb_use'] == 'wd') {
$ratio = $width / $CONFIG['thumb_width'] ;
} else {
$ratio = max($width, $height) / $CONFIG['thumb_width'] ;
}
P.S. the above code has been written off hand and not tested – but will give you the idea ??