首頁  >  文章  >  後端開發  >  php 縮圖實作函數程式碼

php 縮圖實作函數程式碼

高洛峰
高洛峰原創
2016-11-30 09:45:06957瀏覽

array getimagesize ( string $filename [, array &$imageinfo ] ) 取得圖片大小 
resource imagecreatetruecolor ( int $x_size , int $y_size ) 新建一個真彩色圖片映像 
bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $intst_x , int $src_y , int $dst_w , intst_cw , intst_rch ,c,c,rc,w , intst_rcw , intst_rch ,c,c, ,w , intst_rcw , intst_rch_w , int,crc 部分 $大小 
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 以JPEG 格式將圖片輸出到瀏覽器或檔案 
程式碼如下: 
/* 
程式碼如下: 
/* 
程式碼如下: 
=?php 
/* 
程式碼"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; ,$newheight); 

$source = imagecreatefromjpeg($imgfile); 🎜imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $wid, $height); ); 🎜?> 🎜
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn