Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing Images with: imagecopyresampled 1

Status
Not open for further replies.

kennygadams

Programmer
Jan 2, 2005
94
US
I'm trying to copy, resize and save an image to a new folder but nothing happens[hairpull3]! Is the code below written incorrectly?

Code:
$source_image 'full path to the hi-resolution image.jpg';
$destination_image 'full path to the destination of the resized image.jpg';

$source_image_width = '3000';
$source_image_height = '2000';

$destination_image_width = '200';
$destination_image_height = '100';

imagecopyresampled($destination_image,$source_image,0,0,0,0,$destination_image_width,$destination_image_height,$source_image_width,$source_image_height);


Thanks,

kennygadams
 
Be sure to check your error logs, there should be something in there.... The images have to be loaded before you can work with them. This is something I use:

Code:
list($width, $height, $value, $params) = GetImageSize($OrigImage);
$new_width = '200';
$new_height = '100';
$qual = '95'; //Image quality 0-100

if ($width<$height){ $x = $new_height * ($width/$height); $y = $new_height; }else{ $x = $new_width; $y = $new_width / ($width/$height); }  // Center image
$cpyImage = ImageCreateFromJPEG($OrigImage); // Load original image
$newImage = ImageCreateTrueColor($new_width, $new_height); // Create destimation image
ImageCopyResampled($newImage, $cpyImage, ($new_width-$x)/2, ($new_height-$y)/2, 0, 0, $x, $y, $width, $height);
ImageInterlace($newImage, 1);
ImageJPEG($newImage,$NewImageLocation,$qual);

 
Now I'm getting this error when trying to resize an image:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3504 bytes)

How do I increase the size allowed to be processed?

[poke]

Kenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top