php怎么生成图片缩略图

您好,欢迎来到百闽人生网登录 注册

百闽首页 | 考试日历 | 百闽娱乐 | 书信频道 | 节日庆典 | 语录句子 | 免费发布培训课程

百闽人生网

百闽人生网 > 培训新闻 > 电脑/IT > php怎么生成图片缩略图

php怎么生成图片缩略图

具体如下:

这里需要用到GD2 library

function make_thumb($src,$dest,$desired_width)

{

/* read the source image */

$source_image = imagecreatefromjpeg($src);

$width = imagesx($source_image);

$height = imagesy($source_image);

/* find the "desired height" of this thumbnail, relative to the desired width */

$desired_height = floor($height*($desired_width/$width));

/* create a new, "virtual" image */

$virtual_image = imagecreatetruecolor($desired_width,$desired_height);

/* copy source image at a resized size */

imagecopyresized($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, 83);

}


首页 1 2 下页 

关于我们 | 招生合作 | 负责声明 | 常见问题 | 诚聘英才 | 联系我们

Copyright©2014 www.bminlife.com 百闽人生网 版权所有©百闽人生网 闽ICP备14001301号
本文标题:php怎么生成图片缩略图
分站加盟及广告服务QQ:1476191318
友情提示:本站所有信息均由本站注册会员免费发布,如涉及版权问题或虚假信息请及时与本站联系。——我们一直在追求真实!