|
如题:怎样在CI中生成缩略图且不变形?
利用CI的生成缩略图功能,要么可以比例缩放,要么就是裁剪,请教高手,怎样写才能使生成的缩略图能比例缩小而又不变形呢?
我的代码如下,请高手指点:
function image_do($width,$height){
$this->load->library('image_lib');
$config['image_library'] = 'GD2';
$config['source_image'] = 'uploads/ri.gif';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;//使图像保持原始的纵横比例
$config['master_dim'] = 'width';
$config['width'] = $width;
$config['height'] = $height;
$config['x_axis'] = '100';//将图片左边的100像素裁去
$config['y_axis'] = '100';
//$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
if(!$this->image_lib->resize()){
echo $this->image_lib->display_errors();
}
else{
echo "it successes !";
}
} |
|