我添加了用于在codeigniter中调整图像大小的代码。
$configs['image_library'] = 'gd2';
$configs['source_image'] = './userpics/'.$new_name;
$configs['new_image'] = './userpics/userthumb/'.$new_name;
$configs['create_thumb'] = FALSE;
$configs['maintain_ratio'] = TRUE;
$configs['quality'] = '100';
$configs['width'] = 80;
$configs['height'] = 80;
但图像是80 * 45或80 * 60。请让我知道任何解决方案,以便我能够以适当的尺寸显示。
答案 0 :(得分:0)
pl参考
https://ellislab.com/codeigniter/user-guide/libraries/image_lib.html
maintain_ratio:TRUE / FALSE - 指定在调整大小或使用硬值时是否保持原始宽高比。
答案 1 :(得分:0)
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = "Mention your source location here";
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['height'] = "New Width";
$config['width'] = "New Height";
$config['new_image'] = "destination location";//you should have write permission here..
$this->image_lib->initialize($config);
$this->image_lib->resize();