最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php圖像處理函數(shù)imagecopyresampled用法詳解

 更新時間:2016年12月02日 11:15:35   作者:牛逼的霍嘯林  
這篇文章主要介紹了php圖像處理函數(shù)imagecopyresampled用法,結合實例形式詳細分析了imagecopyresampled函數(shù)的功能、參數(shù)、使用方法,需要的朋友可以參考下

本文實例講述了php圖像處理函數(shù)imagecopyresampled用法。分享給大家供大家參考,具體如下:

語法

復制代碼 代碼如下:
bool imagecopyresampled ( 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 )

參數(shù)

dst_image 目標圖象連接資源。
src_image 源圖象連接資源。
dst_x 目標 X 坐標點。
dst_y 目標 Y 坐標點。
src_x 源的 X 坐標點。
src_y 源的 Y 坐標點。
dst_w 目標寬度。
dst_h 目標高度。
src_w 源圖象的寬度。
src_h 源圖象的高度。

成功時返回 TRUE, 或者在失敗時返回 FALSE。

案例

案例(圖像裁減):

<?php
  $targ_w = $targ_h = 150; // 設置目標寬度與高度
  $jpeg_quality = 90; // 圖片質量90,滿分為100
  $src = 'demo_files/pool.jpg'; // 被處理的圖片
  $img_r = imagecreatefromjpeg($src); // 獲取原圖
  $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); // 獲取新圖
  imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
  $targ_w,$targ_h,$_POST['w'],$_POST['h']); // 目標圖 源圖 目標X坐標點 目標Y坐標點 源的X坐標點 源的Y坐標點 目標寬度 目標高度 源圖寬度 源圖高度
  header('Content-type: image/jpeg');
  imagejpeg($dst_r,null,$jpeg_quality); // 輸出圖象到瀏覽器或文件
?>

案例二(重新取樣):

<?php
// 源文件
$filename = '1.jpg';
// 設置最大寬高
$width = 400;
$height = 400;
// Content type
header('Content-Type: image/jpeg');
// 獲取新尺寸
list($width_orig, $height_orig) = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig;
if ($width/$height > $ratio_orig) {
  $width = $height*$ratio_orig;
} else {
  $height = $width/$ratio_orig;
}
// 重新取樣
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// 輸出
imagejpeg($image_p, null, 100);
?>

附上上傳圖片的三種思路

1.選擇圖片,提交表單,服務器統(tǒng)一處理上傳,保存路徑

2.選擇圖片,上傳,獲取路徑,提交表單,保存路徑

3.選擇圖片,上傳到服務器,通過某種途徑獲取到服務器的圖片,保存到本地

更多關于PHP相關內容感興趣的讀者可查看本站專題:《PHP圖形與圖片操作技巧匯總》、《PHP基本語法入門教程》、《PHP運算與運算符用法總結》、《php面向對象程序設計入門教程》、《PHP網絡編程技巧總結》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結》、《php+mysql數(shù)據庫操作入門教程》及《php常見數(shù)據庫操作技巧匯總

希望本文所述對大家PHP程序設計有所幫助。

相關文章

最新評論

库尔勒市| 安顺市| 临武县| 绵竹市| 聊城市| 额敏县| 东海县| 中超| 稻城县| 庐江县| 内乡县| 肇庆市| 西安市| 洮南市| 沅江市| 南阳市| 治县。| 威信县| 沙湾县| 南投市| 宜兰县| 克什克腾旗| 都兰县| 昌乐县| 淮安市| 扎兰屯市| 三都| 镇雄县| 葫芦岛市| 武邑县| 庐江县| 铜川市| 芦溪县| 徐州市| 明星| 垦利县| 墨竹工卡县| 福海县| 剑河县| 信阳市| 乌兰浩特市|