note 15022 added to function.imagecopyresampled.php
| From: | johnp at positivespinmedia dot com | Date: | Fri, 24 Aug 2001 15:35:06 +0000 |
| Subject: | note 15022 added to function.imagecopyresampled.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17079@lists.php.net to get a copy of this message | ||
Here is the code I used to resize a given image:
$src_img = imagecreatefromjpeg("/path/to/$my_src_file");
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width,
$src_height);
imagejpeg($dst_img, "/path/to/storage/new_file.jpg", $quality);
imagedestroy($src_img);
imagedestroy($dst_img);
As mentioned previously, it is very important to use 'imagecreatetruecolor' to allocate
memory for your new image... it will not be the correct color otherwise.
http://www.php.net/manual/en/function.imagecopyresampled.php