class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
$handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 120; $handle->file_new_name_body = $propertyid.'_'.$f.'_thumb'; $handle->image_convert = 'jpg'; $handle->file_auto_rename = false; $handle->file_overwrite = true;