Thanks for reply.
Here is the code I'm using.
// image I want to resize
$img = imagecreatefromjpeg('1.jpg');
// canvas size
$h_canvas = imagesx($img);
$w_canvas = imagesy($img);
$canvas = imagecreatetruecolor($h_canvas, $w_canvas);
// new image size
$h_image = $h_canvas * 0.8;
$w_image = $w_canvas * 0.8;
// start pixel
$x_image = $h_canvas * 0.1;
$y_image = $w_canvas * 0.1;
imagecopyresampled($canvas, $img, $x_image, $y_image, 0, 0, $h_image, $w_image, $h_canvas, $w_canvas);
imagedestroy($img);
imagejpeg($canvas, '11.jpg', 100);
imagedestroy($canvas);
Remember, you've got 2 images in memory.