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

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

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

廢話不多說了,直接給大家貼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);
}
}

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

相關(guān)文章

最新評論

垦利县| 宜都市| 阳城县| 四平市| 理塘县| 卓资县| 安阳县| 吉林省| 泽州县| 突泉县| 岳西县| 镇江市| 七台河市| 若尔盖县| 福清市| 丘北县| 汾阳市| 孝昌县| 白玉县| 峨边| 潢川县| 桐城市| 临猗县| 安平县| 当阳市| 隆子县| 老河口市| 瑞丽市| 郴州市| 托里县| 寿宁县| 吉林市| 琼结县| 额敏县| 寿宁县| 浦县| 丹阳市| 会昌县| 广河县| 花垣县| 伊川县|