【发布时间】:2014-08-29 04:37:42
【问题描述】:
我正在尝试将上传的图像调整为 163 像素的高度,保持纵横比,然后将其上传到文件夹。我尝试使用以下代码:
$id=1; // user id
$this->load->library('image_lib');
$filename=$_FILES['file']['name'];
$config['image_library'] = 'gd2';
$config['upload_path'] = './userdata/'.$id;
$config['height'] = '163px';
$config['maintain_ratio'] = TRUE;
//$config['master_dim'] = 'height';
$config['source_image'] = $filename;
$this->load->library('upload', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
if(!$this->upload->do_upload('file'))
{
echo $this->data['error'] = $this->upload->display_errors();
}
但是,这是将图像上传到正确的文件夹,但图像未调整大小。我上传了大小为 *170*128* 的图像,它按原样上传到文件夹,无需调整大小。我的代码有什么问题?
谁能帮我找出问题所在?
提前致谢。
【问题讨论】:
-
高度需要以px为单位吗?或者你可以只使用“163”吗?
-
应该是
$config['height'] = '163';removepx
标签: php codeigniter image-processing image-resizing