手机
当前位置:查字典教程网 >编程开发 >php教程 >php 缩略图实现函数代码
php 缩略图实现函数代码
摘要:arraygetimagesize(string$filename[,array&$imageinfo])取得图像大小resourceima...

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 <A href="http://www.cnphp.info">http://www.cnphp.info</A>

*/

// 文件及缩放尺寸

//$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);

?>

【php 缩略图实现函数代码】相关文章:

php实现插入排序

php实现求相对时间函数

php eval函数一句话木马代码

php实现window平台的checkdnsrr函数

PHP4中实现动态代理

php实现修改新闻时删除图片的方法

php实现简单的语法高亮函数实例分析

php数组随机排序实现方法

利用php和js实现页面数据刷新

php实现图片转换成ASCII码的方法

精品推荐
分类导航