Codeigniter 图像调整大小? [英] Codeigniter image resize?

查看:29
本文介绍了Codeigniter 图像调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CI 中的图像类有问题?

I have problem with image class in CI?

这是例子

在控制器上:

$this->load->library( array('image_lib') );

我有这个:

    foreach($results as $row)
        {

$config['image_library'] = 'gd2';
$config['source_image'] = '/img/proizvodi/'.$row->proizvodid.'.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']     = 75;
$config['height']   = 50;


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

但是我没有出错,并且没有创建拇指图像?不知道哪里出错了?

But i got no error, and thumb image is not created? I dont know where is mistake?

推荐答案

你不应该在 foreach 中加载 image_lib.尝试使用下面的代码

You shouldn't load image_lib in foreach. Try to use code below

$this->load->library('image_lib');
foreach($results as $row) {
    $config['image_library'] = 'gd2';
    $config['source_image'] = '/img/proizvodi/'.$row->proizvodid.'.jpg';
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width']     = 75;
    $config['height']   = 50;

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

如果它不起作用 - 检查上传文件夹权限.

If it wont work - check the upload folder permissions.

这篇关于Codeigniter 图像调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆