Resizing image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
samir_gambler
Forum Newbie
Posts: 19
Joined: Wed Mar 31, 2010 9:03 am

Resizing image

Post 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....
jbulaswad
Forum Newbie
Posts: 14
Joined: Tue Mar 30, 2010 2:37 pm
Location: Detroit, Michigan, USA

Re: Resizing image

Post 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.
Post Reply