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

PHP  實(shí)現(xiàn)等比壓縮圖片尺寸和大小實(shí)例代碼

 更新時(shí)間:2016年10月08日 14:41:36   投稿:lqh  
這篇文章主要介紹了PHP 實(shí)現(xiàn)等比壓縮圖片尺寸和大小實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下

廢話(huà)不多說(shuō)了,直接給大家貼php等比壓縮圖片大小的相關(guān)代碼了,具體代碼如下所示:

<?php
$im = imagecreatefromjpeg('D:phpplace.jpeg');
resizeImage($im,,,'xinde','.jpg');
function resizeImage($im,$maxwidth,$maxheight,$name,$filetype)
{
$pic_width = imagesx($im);
$pic_height = imagesy($im);
echo "start-----------------" ;
if(($maxwidth && $pic_width > $maxwidth) && ($maxheight && $pic_height > $maxheight))
{
if($maxwidth && $pic_width>$maxwidth)
{
$widthratio = $maxwidth/$pic_width;
$resizewidth_tag = true;
}
if($maxheight && $pic_height>$maxheight)
{
$heightratio = $maxheight/$pic_height;
$resizeheight_tag = true;
}
if($resizewidth_tag && $resizeheight_tag)
{
if($widthratio<$heightratio)
$ratio = $widthratio;
else
$ratio = $heightratio;
}
if($resizewidth_tag && !$resizeheight_tag)
$ratio = $widthratio;
if($resizeheight_tag && !$resizewidth_tag)
$ratio = $heightratio;
$newwidth = $pic_width * $ratio;
$newheight = $pic_height * $ratio;
if(function_exists("imagecopyresampled"))
{
$newim = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($newim,$im,,,,,$newwidth,$newheight,$pic_width,$pic_height);
}
else
{
$newim = imagecreate($newwidth,$newheight);
imagecopyresized($newim,$im,,,,,$newwidth,$newheight,$pic_width,$pic_height);
}
$name = $name.$filetype;
imagejpeg($newim,$name);
imagedestroy($newim);
}
else
{
$name = $name.$filetype;
imagejpeg($im,$name);
}
}

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論

永安市| 吴江市| 长春市| 山西省| 高阳县| 佛山市| 花莲县| 法库县| 伊金霍洛旗| 涞源县| 霍城县| 井冈山市| 浦东新区| 尼玛县| 东海县| 蒲江县| 马尔康县| 阳谷县| 陆河县| 义马市| 昌都县| 蓬安县| 芦山县| 黔西县| 西林县| 浦北县| 安福县| 句容市| 盐山县| 疏附县| 平舆县| 新河县| 竹北市| 万宁市| 呼伦贝尔市| 滕州市| 富锦市| 商洛市| 石台县| 济源市| 阳山县|