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 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技術(shù):php 縮略圖實現(xiàn)函數(shù)代碼,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。