0 2 3624

php的gd库很强大,利用它可以把图片处理成圆角图片。这个例子就是用户上传完图片之后php就在后台把图片处理成了圆角,前端可以直接显示,不需要css的border-radius来处理了。

php把图片变成圆形图片圆角图_图一

php里我定义了三个图片尺寸分别为宽度和高度为50、100和200像素这个你们自己根据需求修改

<?php
/**
 * php修改上传图片的尺寸
 * @author veer
 * @mail veer.mr@qq.com
 */
header("Content-Type: text/html; charset=UTF-8");
$file = $_FILES['file'];
if($file){
    include_once('function_image.php');
    if(!$fileext = check_ispic($file)){
        echo '上传的不是图片';
        exit;
    }
    $attachdir = 'upload/';
    $new_name = $attachdir.'beautiful.'.$fileext;
	$uploadfiles = file_save($file,$new_name);
	$data = array();
	if($uploadfiles){
	    $thumbimgs = array(
    	            'small'=>array('suffix'=>'.thumb.jpg','width'=>50,'height'=>50),
    	            'middle'=>array('suffix'=>'.thumb.jpg.m.jpg','width'=>100,'height'=>100),
    	            'big'=>array('suffix'=>'.thumb.jpg.b.jpg','width'=>200,'height'=>200),
	    );
		foreach ($thumbimgs as $key3=>$val3){
		    $dstfile = $new_name.$val3['suffix'];
		    $tow = $val3['width'];
		    $toh = $val3['height'];
		    $thumbstatus = publicthumb($new_name,$dstfile,$tow,$toh,0);
		    if($thumbstatus){
		       $imgg = radius_img($dstfile, $tow/2);
		       imagejpeg($imgg,$dstfile);
		       imagedestroy($imgg);
		       $data[$key3] = $dstfile;
		    }
		}
	}
}
?>
下载所需: 5金币 下载 演示
[分类]
[来源] http://erlangyun.com/p/id/26.html
[声明] 本站资源来自用户分享,如损害你的权益请联系客服QQ:120074275给予处理。