John Rand
John Rand

Reputation: 1034

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 further 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?

Upvotes: 1

Views: 482

Answers (2)

jfoucher
jfoucher

Reputation: 2281

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';

Upvotes: 2

Bella
Bella

Reputation: 3217

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.

Upvotes: 0

Related Questions