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
ini_set ( "memory_limit", "20M")
php_value memory_limit 20M
Try to raise your local memory to 20M, 32M or more. If you are on shared hosting, you might not be able to do so.
You can add this in your script:
Or in a .htaccess file: