开发者

codeigniter image error

Having a problem with image manipulation in codeigniter - it bombs when I get to $this->image_lib->resize(). I just can't see the error.

Code:

$imagemanip = array();

$imagemanip['image_library'] = 'gd2';

$imagemanip['source_image'] = '/resources/images/butera-fuma-dolce.jpg';

$imagemanip['new_image'] = '/resources/images/thumb_butera-fuma-dolce.jpg';

$imagemanip['create_thumb'] = TRUE;

$imagemanip['maintain_ratio'] = TRUE;

$imagemanip['width'] = 350;

$imagemanip['height'] = 350;


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



if ( ! $this->image_lib->resize()) {

    echo $this->image_lib->display_errors();

}

As I said, it bombs at $this->image_lib->resize(), showing no furth开发者_C百科er output, and does not generate an error.

gd2 is installed (per phpinfo()). I can view the original image with plain html tags. What am I doing wrong?


The path should be relative to the root of your website, where your index.php is located, ie:

don't do this:

$imagemanip['source_image'] = '/resources/images/butera-fuma-dolce.jpg';

do that:

$imagemanip['source_image'] = 'resources/images/butera-fuma-dolce.jpg';

Alternatively, you can use CodeIgniter's absolute path constant, like so:

$imagemanip['source_image'] = FCPATH.'resources/images/butera-fuma-dolce.jpg';


You do not need to specify the 'new_image' config option when using the 'create_thumb' option.

The library will write the file to a file of the same name with a _thumb appended.

Also make sure the correct permissions are set for writing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜