php生成图片缩略图的方法
更新时间:2015年04月07日 11:58:49 作者:不吃皮蛋
这篇文章主要介绍了php生成图片缩略图的方法,涉及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);
}
希望本文所述对大家的php程序设计有所帮助。
相关文章
浅谈PHP接入(第三方登录)QQ登录 OAuth2.0 过程中遇到的坑
下面小编就为大家带来一篇浅谈PHP接入(第三方登录)QQ登录 OAuth2.0 过程中遇到的坑。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-10-10
使用Smarty 获取当前日期时间和格式化日期时间的方法详解
本篇文章是对使用Smarty获取当前日期时间和格式化日期时间的方法进行了详细的分析介绍,需要的朋友参考下2013-06-06
如何利用php array_multisort函数 对数据库结果进行复杂排序
本篇文章是对用php array_multisort函数对数据库结果进行复杂排序进行了详细的分析介绍,需要的朋友参考下2013-06-06
完美解决令人抓狂的zend studio 7代码提示(content Assist)速度慢的问题
本篇文章是对解决令人抓狂的zend studio 7代码提示(content Assist)速度慢的问题进行了详细的分析介绍,需要的朋友参考下2013-06-06


最新评论