中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

PHP調(diào)整圖片尺寸

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
/**********************
 *@filename - path to the image
 *@tmpname - temporary path to thumbnail
 *@xmax - max width
 *@ymax - max height
 */
 function resize_image($filename, $tmpname, $xmax, $ymax)
 {
 $ext = explode(".", $filename);
 $ext = $ext[count($ext)-1];

 if($ext == "jpg" || $ext == "jpeg")
 $im = imagecreatefromjpeg($tmpname);
 elseif($ext == "png")
 $im = imagecreatefrompng($tmpname);
 elseif($ext == "gif")
 $im = imagecreatefromgif($tmpname);

 $x = imagesx($im);
 $y = imagesy($im);

 if($x <= $xmax && $y <= $ymax)
 return $im;

 if($x >= $y) {
 $newx = $xmax;
 $newy = $newx * $y / $x;
 }
 else {
 $newy = $ymax;
 $newx = $x / $y * $newy;
 }

 $im2 = imagecreatetruecolor($newx, $newy);
 imagecopyresized($im2, $im, 0, 0, 0, 0, floor($newx), floor($newy), $x, $y);
 return $im2;
 } 

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:PHP判斷瀏覽器

下一篇:一個php圖片類,將圖片保存為不同尺寸的圖片