注意:ini文件使用php解釋時(shí)為注釋文件,什么也沒有輸出,這是為了安全起見而故意為之。而;則是 " /> www.伊人网,色偷偷av男人的天堂,春水福利app导航

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

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

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

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

我設(shè)置的ini文件例子如下:

復(fù)制代碼 代碼如下:
<?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是一個(gè)數(shù)組,可以選擇任意多個(gè)ini文件中指定的設(shè)置:
復(fù)制代碼 代碼如下:
<?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技術(shù)php批量縮放圖片的代碼[ini參數(shù)控制],轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲人成在线播放无码 | 青柠在线观看免费完整版 | 琪琪电影午夜理论片77网 | SM调教贱屁股眼哭叫求饶H | 国产精品久久久久久久久齐齐 | 浴室里强摁做开腿呻吟的漫画男男 | 国产系列视频二区 | 久久福利影院 | 亚洲AV无码一区二区三区乱子伦 | 亚洲精品久久久久一区二区三 | 成人小视频在线观看 | 亚洲色欲啪啪久久WWW综合网 | 亚洲AV久久无码高潮喷水 | 国产97碰免费视频 | 在线观看亚洲AV无码每日更新 | 亚洲AV无码乱码国产精品品麻豆 | 99精品视频免费在线观看 | yellow片在线观看免费观看动漫 | 在线观看黄色小说 | 久久影院毛片一区二区 | 国产亚洲精品久久久久5区 国产亚洲精品久久久久 | 4399日本电影完整版在线观看免费 | 国产高清亚洲日韩字幕一区 | 精品国产手机视频在在线 | 再插深点嗯好大好爽 | 国产精品资源网站在线观看 | 蜜柚免费视频高清观看在线 | 金发欧美一区在线观看 | 香蕉eeww99国产精选播放 | 国产AV白丝爆浆在线播放 | 麻生希第一部快播 | 一个人看的WWW高清电影 | 国产h视频在线观看网站免费 | 成人在免费视频手机观看网站 | 337p欧洲亚大胆精品 | 午夜伦理:伦理片 | 美女18毛片免费视频 | 亚洲1区2区3区精华液 | 久久精品久久久久 | 99国产精品人妻无码免费 | GOGOGO高清免费播放 |