跳转到主内容
新派编程网 - 新潮编程理念,全新技术课堂!

php 缩略图实现函数代码

array getimagesize ( string $filename [, array &$imageinfo ] ) 取得图像大小resource imagecreatetruecolor ( int $x_size , int $y_size ) 新建一个真彩色图像resource imagecreatefromjpeg ( string $filename ) 从 JPEG 文件或 URL 新建一图像bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 拷贝部分图像并调整大小bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 以 JPEG 格式将图像输出到浏览器或文件复制代码代码如下:php/*Created by http://www.cnphp.info*/// 文件及缩放尺寸//$imgfile = 'smp.jpg';//$percent = 0.2;header('Content-type: image/jpeg');list($width, $height) = getimagesize($imgfile);$newwidth = $width * $percent;$newheight = $height * $percent;$thumb = ImageCreateTrueColor($newwidth,$newheight);$source = imagecreatefromjpeg($imgfile);imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);imagejpeg($thumb);?>

相关文章