Php 如何在codeigniter中调整图像大小
我正在使用codeigniter上载库,我想调整图像的大小。但是当我运行代码时,它会保存图像,但不会调整图像的大小。以下是我的php代码:Php 如何在codeigniter中调整图像大小,php,codeigniter,Php,Codeigniter,我正在使用codeigniter上载库,我想调整图像的大小。但是当我运行代码时,它会保存图像,但不会调整图像的大小。以下是我的php代码: $this->load->library('upload'); $config['upload_path'] = APPPATH .'../images/student'; $config['allowed_types'] = 'gif|jpe
$this->load->library('upload');
$config['upload_path'] = APPPATH .'../images/student';
$config['allowed_types'] = 'gif|jpeg|jpg|png';
$config['max_size'] = '2000';
$config['maintain_ratio']= FALSE;
$config['master_dim'] = 'auto';
$config['width'] = 128;
$config['height'] = 128;
$config['overwrite'] = FALSE;
//initialize
$this->upload->initialize($config);
看起来您需要使用以下各项:
$config['max_width'] = '128';
$config['max_height'] = '128';
注意max\u width
而不是width
所指出的,您需要使用。upload类仅帮助您上载图像,而不是调整图像大小
宽度和高度配置用于限制您可以上载的图像的大小。$config['overwrite']=FALSE有什么影响?我也在问你有没有错?它是否成功上载图像?是的,图像已成功上载,但不会调整大小,不,我没有任何错误。警告:当存在同名的重复图像时,它不会替换它。是否调用:
$this->image_lib->resize()
?在哪里设置图像库?阅读此处:当我将其更改为此代码时,出现了一个错误,它显示:“您尝试上载的图像超出了最大高度或宽度。”我只想将图像大小调整为128x128。谢谢你的回答,但如果这有帮助的话,它不起作用