注意:ini文件使用php解釋時為注釋文件,什么也沒有輸出,這是為了安全起見而故意為之。而;則是 " /> 2019中文字幕乱码免费,伊人青青久,在线成 人av影院

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php批量縮放圖片的代碼[ini參數控制]

首先使用一個ini文件來設置要縮放的大小,其中為寬或高0的則為圖片放大或縮小,都為0則還是原大小,都不為0都拉抻成指定的大小。

注意:ini文件使用php解釋時為注釋文件,什么也沒有輸出,這是為了安全起見而故意為之。而;則是ini文件的注釋。

我設置的ini文件例子如下:

復制代碼 代碼如下:
<?php
/*
;Translate the image format using the original image size
[Translation]
width=0
height=0

;Stretch the image to the specified size
[Stretch]
width=800
height=600

;Zoom the image to the specified Width with height auto size
[AutoHeight]
width=740
height=0

;Zoom the image to the specified Height with width auto size
[AutoWidth]
width=0
height=380
*/
?>

下面是編寫的縮放圖片的php代碼,其中變量classes是一個數組,可以選擇任意多個ini文件中指定的設置:
復制代碼 代碼如下:
<?php
$oimg = "test.jpg";//Original image name
$classes = array('Translation','AutoHeight','AutoWidth','Stretch');//Give classes for the new creating images' size which are defined in the specified ini file
$suffix = 'jpg';//The new image's suffix
$inifile = 'image.ini.php';

$size = getimagesize($oimg);
$x = $size[0]/$size[1];
$name = explode('.',$oimg);

if(!file_exists($inifile)) die('Ini file does not exist!');
$cn = parse_ini_file($inifile,true);//Parse the class style image size from ini file
foreach($classes as $class){
foreach($cn as $k=>$v){
if($k==$class){
if($v['width'] && $v['height']){
$thumbWidth = $v['width'];
$thumbHeight = $v['height'];
}elseif($v['width']){
$thumbWidth = $v['width'];
$thumbHeight = round($thumbWidth/$x);
}elseif($v['height']){
$thumbHeight = $v['height'];
$thumbWidth = round($thumbHeight*$x);
}else{
$thumbWidth = $size[0];
$thumbHeight = $size[1];
}
break;
}
}
if(!isset($thumbHeight) && !isset($thumbWidth)) die('Ini file Settings error!');

$nimg = $name[0].'_'.$class.'.'.$suffix;//New image file name
$source = imagecreatefromjpeg($oimg);
$thumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumb,$source,0,0,0,0,$thumbWidth,$thumbHeight,$size[0],$size[1]);

if($suffix=='jpg') $method = 'imagejpeg';
else $method='image'.$suffix;
$method($thumb, $nimg);
imagedestroy($thumb);//Release the image source
imagedestroy($source);
}
?>

php技術php批量縮放圖片的代碼[ini參數控制],轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产精品九九久久 | 免费的好黄的漫画 | 国产成人精品免费视频大全办公室 | 无码国产成人777爽死在线观看 | 女攻男受高h全文肉肉 | 真实的强视频免费网站 | 男人和女人一起愁愁愁很痛 | 神马老子影院午夜伦 | 草莓国产视频免费观看 | 久久青草免费线观最新 | 精品麻豆一卡2卡三卡4卡乱码 | 三级黄色在线视频 | 国产自产第一区c国产 | 久久99re2在线视频精品 | 在线观看中文 | 波野结衣qvod | 第一精品福利导福航 | 欧美午夜精品A片一区二区HD | 欧美xxxxx九色视频免费观看 | 日本无码专区亚洲麻豆 | 2018久久视频在线视频观看 | 国产传媒麻豆剧精品AV | 国产精片久久久久久婷婷 | 欧美同志高清vivoeso | 男人天堂2018亚洲男人天堂 | 男人插曲女人的视频 | 武侠古典久久亚洲精品 | 无码欧美毛片一区二区三在线视频 | 美女脱精光让男生桶下面 | 两个客户一起吃我的奶 | 国产欧美一区二区三区免费 | 亚洲伊人久久综合影院2021 | 在线看无码的免费网站 | 香蕉久久夜色精品国产小优 | 亚洲破处女 | 女警被黑人20厘米强交 | 日本xxx片免费高清在线 | 91女神娇喘| 亚洲风情无码免费视频 | 九九久久国产精品免费热6 九九久久国产精品大片 | 国产在线观看免费观看 |