php生成图片缩略图的方法

yipeiwu_com6年前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简单定时执行任务的实现方法

本文实例讲述了php简单定时执行任务的实现方法。分享给大家供大家参考。具体实现方法如下: <?php ignore_user_abort(); set_time_lim...

php使用curl判断网页404(不存在)的方法 原创

本文实例讲述了php使用curl判断网页404(不存在)的方法。分享给大家供大家参考,具体如下: <?php /* php使用curl判断404 * Created...

php上传大文件设置方法

打开php.ini,首先找到 ;;;;;;;;;;;;;;;; ; file uploads ; ;;;;;;;;;;;;;;;; 区域,有影响文件上传的以下几个参数: file...

PHP开发中四种查询返回结果分析

1.<!--使用mysql_result()来获取数据--> 复制代码 代码如下: <?php $connection=mysql_connect("localhost...

PHP+apc+ajax实现的ajax_upload上传进度条代码

PHP+apc+ajax实现的ajax_upload上传进度条代码

本文实例讲述了PHP+apc+ajax实现的ajax_upload上传进度条代码。分享给大家供大家参考,具体如下: 上传进度条是怎么实现的呢?原理是怎么样的呢?当我们浏览...