Image Resizing while uploading data from form field to db

Hi All,
In my coding when user uploads image I need to resize the image(resize into a fixed size) and then store the value into db. How can I do it any help plz

copy($originalimage, $image);

$src_img = imagecreatefromjpeg($image);

$dst_img = imagecreatetruecolor($width, $height);

$src_dimensions = getimagesize($image);
$src_width = $src_dimensions[0];
$src_height = $src_dimensions[1];

$prop_src = $src_width/$src_height;
$prop_dst = $width/$height;

if( $prop_src > $prop_dst ){
    $dst_height = $height;
    $dst_width = $src_width*$height/$src_height;
    $prop_crop = $src_height/$height;
    $src_point_x = abs($src_width-$width*$prop_crop)/2;
    $src_point_y = 0;
} else {
    $dst_width = $width;
    $dst_height = $src_height*$width/$src_width;
    $prop_crop = $src_width/$width;
    $src_point_x = 0;
    $src_point_y = abs($src_height-$height*$prop_crop)/2;
}

imagecopyresampled($dst_img, $src_img, 0, 0, $src_point_x, $src_point_y, $dst_width, $dst_height, $src_width, $src_height);

imagejpeg($dst_img, $image);

Why do you copy the image file before doing this? You’re gonna fill up the directory with copies of big images that weren’t intended to stay around.

I usually copy the image first from the initially uploaded dir to a thumbnails dir where I change the size(s). That way I still have the ability to create other thumbnails of it.
This is handy when having to create 4 or more different sized thumbnails for each image.