国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php實現(xiàn)圖片按比例截取的方法

2024-05-04 23:55:06
字體:
供稿:網(wǎng)友

本文實例講述了php實現(xiàn)圖片按比例截取的方法。分享給大家供大家參考,具體如下:

filename = 'img/test.jpg';$all_type = array("jpg"  => array("create"=>"ImageCreateFromjpeg", "output"=>"imagejpeg"  , "exn"=>".jpg"),"gif"  => array("create"=>"ImageCreateFromGIF" , "output"=>"imagegif"  , "exn"=>".gif"),"jpeg"  => array("create"=>"ImageCreateFromjpeg", "output"=>"imagejpeg"  , "exn"=>".jpg"),"png"  => array("create"=>"imagecreatefrompng" , "output"=>"imagepng"  , "exn"=>".png"),"wbmp"  => array("create"=>"imagecreatefromwbmp", "output"=>"image2wbmp" , "exn"=>".wbmp"));$imgtype = getimagesize($filename);$width = $imgtype[0];$height = $imgtype[1];$type = str_replace('image/','',$imgtype['mime']);$func_create = $all_type[$type]['create'];$func_output = $all_type[$type]['output'];$x = $y =0;if(($width * 100)>($height * 120)){$newwidth = ceil($height * 120/100);$newheight = $height;$x = ($width-$newwidth)/2;}elseif(($width * 100)<($height * 120)){$newheight = ceil($width * 100/120);$newwidth = $width;$y = ($height-$newheight)/2;}else{$newheight = $height;$newwidth = $width; }// Load$thumb = imagecreatetruecolor($newwidth, $newheight);$source = $func_create($filename);// Resizeimagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $newwidth, $newheight);// Output$func_output($thumb,'a.jpeg');

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


注:相關(guān)教程知識閱讀請移步到PHP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 中阳县| 凤城市| 惠安县| 余姚市| 十堰市| 明溪县| 新郑市| 休宁县| 元氏县| 肃北| 扎赉特旗| 芮城县| 永宁县| 广水市| 靖远县| 治多县| 清徐县| 新乐市| 铁岭县| 南木林县| 长垣县| 忻州市| 马山县| 巧家县| 特克斯县| 娄底市| 尖扎县| 海安县| 商城县| 平安县| 台山市| 海丰县| 沂源县| 靖宇县| 九龙城区| 平乐县| 隆化县| 天全县| 灵宝市| 芜湖市| 鸡泽县|