您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 缩略图实现函数代码

2025/9/20 13:50:48发布23次查看
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.php1.cn/">*/ 
// 文件及缩放尺寸 
//$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); 
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product