注意:ini文件使用php解釋時為注釋文件,什么也沒有輸出,這是為了安全起見而故意為之。而;則是 " /> GAY空少被体育生开菊,久久久久综合网,国产盗摄TP摄像头偷窥

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

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

首先使用一個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是一個數(shù)組,可以選擇任意多個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參數(shù)控制],轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 欧美成人无码视频午夜福利 | 国产精品国产三级国产AV麻豆 | 八妻子秋霞理在线播放 | 白丝美女被狂躁免费漫画 | 99久久国内精品成人免费 | 国产精品系列在线一区 | 娇小XXXXX第一次出血 | 善良的小峓子2在钱免费中文字 | 蜜柚视频网在线观看免费 | 精品国产在线国语视频 | 男人插曲视频大全免费网站 | 粗暴玩烂货调教 | 日本熟妇乱人伦A片精品软件 | 欧美白妞大战非洲大炮 | 免费看的一级毛片 | 亚洲国产精品一区二区久久第 | 99精品电影一区二区免费看 | 首页 国产 亚洲 中文字幕 | 99精品电影一区二区免费看 | 秋霞av伦理片在线观看 | 久久综合亚洲色hezyo | 处 女 开 破小说 | 久久综合亚洲色hezyo | 日本大尺码喷液过程视频 | 青青青手机视频 | 国产精品v片在线观看不卡 国产精品v欧美精品v日韩 | 欧美多毛的大隂道 | 久久re这里视频只精品首页 | 教室里的激情电影 | 北条麻妃久久99精品 | JIZJIZJIZ 日本老师水多 | 久久综合久久鬼色 | 国产亚洲精品网站在线视频 | 91av电影在线观看 | 精品亚洲一区二区三区在线播放 | 亚洲中文日韩日本在线视频 | 久久视频在线视频观看天天看视频 | 成人免费一级毛片在线播放视频 | 高清无码中文字幕在线观看视频 | 乳色吐息未增删樱花ED在线观看 | 国产免费内射又粗又爽密桃视频 |