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

PHP 圖像尺寸調(diào)整代碼

 更新時(shí)間:2010年05月26日 00:02:21   作者:  
創(chuàng)建圖像縮略圖需要許多時(shí)間,此代碼將有助于了解縮略圖的邏輯。
復(fù)制代碼 代碼如下:

/**********************
*@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;
}

這里是摘自腳本之家之前發(fā)布的文章。更多的技巧可以參考。
收集的二十一個(gè)實(shí)用便利的PHP函數(shù)代碼

相關(guān)文章

最新評論

汉寿县| 平邑县| 新源县| 唐河县| 东光县| 淮北市| 黄山市| 吉林省| 陇南市| 宜兰市| 读书| 河东区| 晋中市| 韩城市| 克拉玛依市| 柳州市| 滕州市| 通河县| 大厂| 阿克陶县| 德化县| 台东县| 杨浦区| 宝清县| 马边| 黎川县| 鸡泽县| 永寿县| 巨野县| 天祝| 涡阳县| 横山县| 遂川县| 康马县| 庆云县| 平原县| 建瓯市| 梅河口市| 金溪县| 西乌珠穆沁旗| 澄迈县|