Page 1 of 1

Resizing image

Posted: Wed Mar 31, 2010 9:16 am
by samir_gambler
I know imagecopyresampled is used to resize the image bt I m unable to understand its parameter
bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
resource $dst_image -->Destination image link resource. But what exactly does it means.....
as when i tries to echo it from an example it returns Resource id #10 PLZ HELP....

Re: Resizing image

Posted: Wed Mar 31, 2010 10:23 am
by jbulaswad
Samir,

Without knowing what your end result is or where you are trying to place this image, this snippet of code might help you in whatever you are attempting to accomplish:

Code: Select all

// Fetch existing image
$objOriginalImage = imagecreatefromjpg('myImage.jpg');
// Create new image
$objResizedImage = imagecreatetruecolor(400, 400);
// Resize
imagecopyresampled($objResizedImage, $objOriginalImage, 0, 0, 0, 0, 200, 200, 400, 400);
// Save resized image
imagejpeg($objResizedImage, 'myImageResized.jpg', 100);
The functions used may vary depending on the image type and desired output.

Hope that helps.