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
$foo = $this->load->library('someclass'); $this->someclass->init($_FILES['form_field']); $this->someclass->image_resize(true);
etc.... It is one way to do it, but you can pass all the parameters in a different fashion.
Your library will then wrap the class.upload, and within the library, you will instantiate the upload class, set the parameters, etc...
I don't have the time to try, but that gives you an idea.