简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

php生成图片缩略图的方法

来源:易贤网   阅读:719 次  日期:2015-04-17 09:33:00

温馨提示:易贤网小编为您整理了“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);

}

更多信息请查看IT技术专栏

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:PHP中把对象转换为关联数组代码分享
下一篇:php生成zip文件类实例
易贤网手机网站地址:php生成图片缩略图的方法
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!