简体   繁体   English

Codeigniter图像调整大小库无法正常工作

[英]Codeigniter image resize library not working properly

for($i=0; $i< count($data['upload_data']); $i++){

                //resize uploade image
                $config['image_library'] = 'gd2';
                $config['source_image'] = $data['upload_data'][$i]['full_path'];
                $config['new_image'] = $data['upload_data'][$i]['full_path'];
                $config['maintain_ratio'] = TRUE;
                $config['width']    = 700;
                $config['height']   = 700;

                $this->load->library('image_lib', $config); 

                $this->image_lib->resize(); 
                $this->image_lib->clear();
}

I want to resize the images in a loop, all the images are already in the database, but after running this script, only the first image is resized. 我想循环调整图像的大小,所有图像已经在数据库中,但是在运行此脚本后,仅调整了第一个图像的大小。

All the path are correct, anyone else encountering this problem? 所有路径都是正确的,还有其他人遇到此问题吗?

After loading image_lib you might need to initialize it. 加载image_lib之后,您可能需要对其进行初始化。

$this->load->library('image_lib', $config); 

$this->image_lib->initialize($config);

See: https://ellislab.com/codeigniter/user-guide/libraries/image_lib.html 参见: https : //ellislab.com/codeigniter/user-guide/libraries/image_lib.html

You will NOT need to use the $this->image_lib->initialize function if you save your preferences in a config file. 如果将首选项保存在配置文件中,则无需使用$ this-> image_lib-> initialize函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM