Try this...
Right Before line 318, before this line:
PHP Code:
imagecopyresized($imgresized, $imgsoruce, 0, 0, 0, 0, $thumb_width, $thumb_height, $imgdata[0], $imgdata[1]);
Try adding this:
PHP Code:
$x=$imgdata[0]/$thumb_width;
$y=$imgdata[1]/$thumb_height;
If($y > $x){
$thumb_width=round($imgdata[0] * (1 / $y));
$thumb_height=round($imgdata[1] * (1 / $y));
} Else {
$thumb_width=round($imgdata[0] * (1 / $x));
$thumb_height=round($imgdata[1] * (1 / $x));
}
This is untested... Let me know if it works.