如何在循环 codeigniter 中处理图像?
我有两个调整大小函数,我想使用 codeigniters 图像操作类一个接一个地执行:http://codeigniter.com/user_guide/libraries/image_lib.html
目前,当我尝试运行该函数时,只有第一个函数有效,它忽略第二个。
我添加了 $this->image_lib->clear()
,根据 codeigniters 用户指南:“重置处理图像时使用的所有值。”如果您正在循环中处理图像,您将需要调用它。
为什么我无法运行两个单独的调整大小函数?我该怎么做呢?
$image_data = $this->upload->data();
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $upload_path . '/thumbs/',
'maintain_ration' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$config = array(
'source_image' => $image_data['full_path'],
'maintain_ration' => true,
'width' => 620,
'height' => 410
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
I have two resize functions that I would like to perform one after the other using codeigniters image manipulation class:http://codeigniter.com/user_guide/libraries/image_lib.html
At the moment when I try running the function only the first one works, it ignores the second.
I have added $this->image_lib->clear()
which according to codeigniters user guide: 'resets all of the values used when processing an image. You will want to call this if you are processing images in a loop.'
Why can't I run the two seperate resize functions? How would I go about doing this??
$image_data = $this->upload->data();
$config = array(
'source_image' => $image_data['full_path'],
'new_image' => $upload_path . '/thumbs/',
'maintain_ration' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$this->image_lib->clear();
$config = array(
'source_image' => $image_data['full_path'],
'maintain_ration' => true,
'width' => 620,
'height' => 410
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想使用清除,则将配置存储在两个不同的数组中。
$this->image_lib->clear(); 用于刷新以前的设置和添加新的。
If you don't want to use clear then store configs in two different arrays.
$this->image_lib->clear(); is used to flush previous settings & to add new.