欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php 縮略圖實現(xiàn)函數(shù)代碼

 更新時間:2011年06月23日 22:30:11   作者:  
php 生成縮略圖函數(shù)非常簡單,只是調(diào)入了幾個GD的系統(tǒng)函數(shù),不過卻很實用
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 ) 拷貝部分圖像并調(diào)整大小
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 以 JPEG 格式將圖像輸出到瀏覽器或文件
復(fù)制代碼 代碼如下:

<?php
/*
Created by <A >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);
?>

相關(guān)文章

最新評論