您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

一款php批量生成缩略图代码_PHP教程

2024/7/24 3:12:42发布32次查看
$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代码,其中变量classes是一个数组,可以选择任意多个ini文件中指定的设置:
这是一个ini配置文件,上面的代码就要读取这个文件中的图片位置,可以多个。
注意:ini文件使用php解释时为注释文件,什么也没有输出,这是为了安全起见而故意为之。而;则是ini文件的注释。
http://www.bkjia.com/phpjc/632987.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/632987.htmltecharticle?php教程 $oimg = test.jpg;//original image name $classes = array('translation','autoheight','autowidth','stretch');//give classes for the new creating images' size which are defi...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product