Use the Upload Class written by Colin Verot. It has all sorts of options for resizing, editing, watermarking etc... It's awesome!!
The class is maintained and used by websites all over the internet so you can rely on it to be reliable!
See here
Even though this is called the Upload Class, you can apply the same methods to files already on your server
How to Use
Follow the installation instructions on the site, quite simply, download the class and place it in your site.
Your script will then look something like this:
// Include the upload class
include('class.upload.php');
// Initiate the upload object based on the uploaded file field
$handle = new upload($_FILES['image_field']);
// Only proceed if the file has been uploaded
if($handle->uploaded) {
// Set the new filename of the uploaded image
$handle->file_new_name_body = 'image_resized';
// Make sure the image is resized
$handle->image_resize = true;
// Set the width of the image
$handle->image_x = 100;
// Ensure the height of the image is calculated based on ratio
$handle->image_ratio_y = true;
// Process the image resize and save the uploaded file to the directory
$handle->process('/home/user/files/');
// Proceed if image processing completed sucessfully
if($handle->processed) {
// Your image has been resized and saved
echo 'image resized';
// Reset the properties of the upload object
$handle->clean();
}else{
// Write the error to the screen
echo 'error : ' . $handle->error;
}
}