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

PHP原比例生成縮略圖

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
<?php
$image = "jiequ.jpg"; // 原圖
$imgstream = file_get_contents($image);
$im = imagecreatefromstring($imgstream);
$x = imagesx($im);//獲取圖片的寬
$y = imagesy($im);//獲取圖片的高

// 縮略后的大小
$xx = 140;
$yy = 200;

if($x>$y){
//圖片寬大于高
    $sx = abs(($y-$x)/2);
    $sy = 0;
    $thumbw = $y;
    $thumbh = $y;
} else {
//圖片高大于等于寬
    $sy = abs(($x-$y)/2.5);
    $sx = 0;
    $thumbw = $x;
    $thumbh = $x;
  }
if(function_exists("imagecreatetruecolor")) {
  $dim = imagecreatetruecolor($yy, $xx); // 創(chuàng)建目標圖gd2
} else {
  $dim = imagecreate($yy, $xx); // 創(chuàng)建目標圖gd1
}
imageCopyreSampled ($dim,$im,0,0,$sx,$sy,$yy,$xx,$thumbw,$thumbh);
header ("Content-type: image/jpeg");
imagejpeg ($dim, false, 100);
?>

標簽:

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

上一篇:Android MD5加密算法

下一篇:Android監(jiān)聽輸入框返回按鍵