Yuv*_*val 1 php gd image-resizing
我目前正在使用php gd实现来调整不断耗尽内存的图像 - 相当快.我猜问题是php函数,比如imagecreatefromstring等.
是否有一个简单的实现来调整不使用此功能的图像,所以我不必增加我的php.ini内存限制?
这是一个PHP函数
function make_thumb($src, $dest, $desired_width,$desired_h) {
/* read the source image */
$source_image = imagecreatefromjpeg($src);
$width = imagesx($source_image);
$height = imagesy($source_image);
$desired_height = $desired_h;
/* create a new, "virtual" image */
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
/* copy source image at a resized size */
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
/* create the physical thumbnail image to its destination */
imagejpeg($virtual_image, $dest);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6472 次 |
| 最近记录: |