Problem resizing image using Code Ignitor1.7.3

风流意气都作罢 提交于 2019-12-25 04:44:56

问题


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); 
}

回答1:


For a start, remove the

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

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

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

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.

I guess that's all.



来源:https://stackoverflow.com/questions/4496428/problem-resizing-image-using-code-ignitor1-7-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!