views:

31

answers:

2

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?

A: 

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.

DRL
I am aware that the "new_image" config option is not required. Eliminating it does not help."...correct permissions are set for writing." I'm developing on my laptop running XP, instead of a unix box this time. Are permissions a factor?
John Rand
+1  A: 

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';
jfoucher
+1 should have spotted that myself (or do this ./)
DRL