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.
I've this piece of code which works perfectly on Windows but does not work in Linux VPS. On Windows I can overwrite the image with a new one, convert to 'jpg' and also resize to 128x128. I checked the logs
$foo->log says -no image processing wanted
image 'upload' directory has permission set to 755 drwxr-xr-x 3 apache apache 4096 May 26 15:03 uploads
$foo->log says
-no image processing wanted
image 'upload' directory has permission set to 755
drwxr-xr-x 3 apache apache 4096 May 26 15:03 uploads
My php.ini
memory_limit = 128M
$foo = new upload ( $file ); if ($foo->uploaded) { if ($info [2] !== IMAGETYPE_JPEG) { $foo->image_convert = 'jpg'; } // check width and height if ($info [0] > 750 || $info [1] > 540) { $foo->image_resize = true; $foo->image_ratio_crop = true; $foo->image_x = 750; $foo->image_y = 540; } // save uploaded image with a new name $foo->file_new_name_body = $fileName; $foo->file_overwrite = true; $foo->process ( $filePathOnServer ); if (! $foo->processed) { reportErrorAndExit ( $foo->error ); } // profile - 128px, others - 38px $foo->file_new_name_body = $fileName . '_thumbnail'; $foo->file_overwrite = true; $foo->image_convert = 'jpg'; $foo->image_resize = true; $foo->image_ratio_crop = true; $foo->image_x = 128; $foo->image_y = 128; $foo->process ( $filePathOnServer ); if ($foo->processed) { $foo->clean (); echo JSON_SUCCESS; } else { reportErrorAndExit ( $foo->error ); } }