In includes/image_utils.php find:
if ($resize_handle($src, $dest, $quality, $width_height['width'], $width_height['height'], $image_info)) {
Insert above: global $config;
$width_height = array("width" => $config['max_thumb_width'], "height" => $config['max_thumb_height']);