使用代码Ignitor1.7.3调整图像大小问题 [英] Problem resizing image using Code Ignitor1.7.3

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

问题描述

以下是调整图片大小的代码,但我无法调整图片大小

Following is the code which resize the image, but here i am not able to resize the image

function processHome(){  
    $this->load->library('image_lib');

    $img_path =  base_url().'img/image/50X50/ori.jpeg';

    $config['image_library'] = 'gd2';
    $config['source_image'] = $img_path;
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width'] = 50;
    $config['height'] = 50;

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

    if ( ! $this->image_lib->resize()){
        echo $this->image_lib->display_errors();
    }

    echo "No error";
    exit;

    $this->load->view('index', $data); 
}


推荐答案

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

开头 - 您只需要加载库一次,并且只有在您设置参数后。

at the beginning - you only need to load the library once, and only after you set the parameters.

然后,给出图像文件夹的相对/服务器路径,而不是url - 如base,no base_url()。

Then, give the relative/server path to your image folder, instead of the url - as in, no base_url().

最后,检查映像所在文件夹的权限 - 它必须是可读/可写的,并且应允许php创建新文件。

Finally, check the permissions for the folder the image is in - it must be readable/writable by all, and php should be allowed to create new files.

我想这就是所有。

这篇关于使用代码Ignitor1.7.3调整图像大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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