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生成图片缩略图类。分享给大家供大家参考,具体如下: class App_image_helper { protected $imgFileName; pr...

EPSON打印机 连供墨水系统 维修有哪些保养窍门第1/2页

这种堵塞会导致喷出的墨滴变小或喷出的墨水有明显的分叉现象,使墨滴在纸上的覆盖率不足,同时还会导致喷出的墨水飞斜,在纸上的定位产生偏移,这样打印出的图稿就让人感觉颗粒偏粗。严重的堵塞就造成...

关于zend studio 出现乱码问题的总结

出现乱码的地方大概有4个地方:1、文件的编码方式(就是你新建文件的编码),这一点需要设置编辑器的编码方式。2、页面没有指定浏览器编码的显示方式,这一点解决的办法是:1,如果页面是.htm...

PHP中数据类型转换的三种方式

PHP的数据类型转换属于强制转换,允许转换的PHP数据类型有: 1.(int)、(integer):转换成整形 2.(float)、(double)、(real):转换成浮点型 3.(s...

PHP strtok()函数的优点分析

其优点是: 1、可以一次定义多个分隔符。函数在执行时,是按单个分隔符来切割,而不是按整个分隔符,而explode则是按整个分隔串来切割的。正因此,explode可以用中文切割,而str...