注意:ini文件使用php解釋時為注釋文件,什么也沒有輸出,這是為了安全起見而故意為之。而;則是 " /> 人C交ZZZ0OOZZZ000,亚洲成人一区,羞羞影院午夜男女爽爽影院网站

天天躁日日躁狠狠躁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參數控制],轉載需保留來源!

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

主站蜘蛛池模板: 18禁止看的免费污网站 | 人妻美妇疯狂迎合 | 99久久re6热精品首页 | 亚洲色噜噜狠狠站欲八 | 国产精品色吧国产精品 | 国产精品资源在线观看网站 | 午夜成a人片在线观看 | 最近日本字幕免费高清 | 国产AV麻豆出品在线播放 | 久久精品麻豆国产天美传媒果冻 | 永久精品免费影院在线观看网站 | 含羞草国产亚洲精品岁国产精品 | 中文字幕人成人乱码亚洲AV | 成人免费一级毛片在线播放视频 | 边摸边吃奶玩乳尖视频 | 欧美日韩中文国产一区 | 99视频在线观看视频 | 嗯好大好猛皇上好深用力 | 国产午夜精品理论片久久影视 | 久久久久久极精品久久久 | 忘忧草研究院一二三 | 亚洲精品AV一区午夜福利 | 日韩1区1区产品乱码芒果榴莲 | 啦啦啦WWW在线观看免费高清版 | 国产成人在线免费 | 亚洲另类中文字幕 | 两个客户一起吃我的奶 | 国产人妻麻豆蜜桃色在线 | 国产精品人妻无码久久久2022 | 国产三级影院 | 日韩一级精品久久久久 | 午夜伦理在线观看 | 国产午夜精品AV一区二区麻豆 | 囯产精品久久久久免费蜜桃 | 全球真实小U女视频合集 | 主播蜜汁丝袜精品自拍 | 探花口爆颜射乳交日韩 | 小草高清视频免费直播 | 日韩 国产 欧美视频二区 | 色老板美国在线观看 | 精品国产免费第一区二区 |