CodeIgniter调整图像大小

时间:2012-06-05 12:58:07

标签: codeigniter

我的脚本是:

public function resize_image($dir, $new_name, $image, $width, $height)
{
$img_cfg_thumb['image_library'] = 'gd2';
$img_cfg_thumb['source_image'] = "./" . $dir . "/" . $image;
$img_cfg_thumb['maintain_ratio'] = TRUE;
$img_cfg_thumb['new_image'] = $new_name;
$img_cfg_thumb['width'] = 200;
$img_cfg_thumb['height'] = 200;
$this->load->library('image_lib');
$this->image_lib->initialize($img_cfg_thumb);
$this->image_lib->resize();
}

但它只会创建 200 x 150

的缩略图

1 个答案:

答案 0 :(得分:3)

您的原始图片尺寸是多少?

因为

 $img_cfg_thumb['maintain_ratio'] = TRUE;

尝试将其设置为false