Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image_lib in CodeIgniter not working... code just stops... no error, nothing

For the life of me, I can't figure out why image_lib (the image manipulation library) in CodeIgniter isn't working. I have it working perfectly fine on my local machine, so I know the code is right. But when I upload to a production server, trying to create a thumbnail from an image just stops the code dead in its tracks.

The kicker is that image_lib isn't spitting back an error message... the page just stops at that point... Here's my code snippet

$config = array(
    'source_image' => '/data/servers/misc/www_thesite_com/files/originals/thepicture.jpg',
    'new_image' => '/data/servers/misc/www_thesite_com/files/thumbs',
    'maintain_ratio' => true,
    'create_thumb' => true,
    'width' => 150,
    'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$ThumbnailName = 'thepicture_thumb.jpg';

I've tried checking using the following code too:

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

But, nothing happens. Everything just stops at $this->image_lib->resize(); without throwing any error whatsoever.

One other note... GD2 is successfully installed. I'm able to perform other standard image manipulation without a hitch when not using CodeIgniter.

Any ideas?

like image 443
Jonathan Avatar asked Sep 12 '26 17:09

Jonathan


2 Answers

I had the same problem and I fixed this using

$this->image_lib->initialize($config);

just after

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

It seems that giving the configuration when you load the library isn't enough and you need to initialize

like image 94
Basile Avatar answered Sep 15 '26 11:09

Basile


If no code executes after your function call, I'd expect the problem to be server related. This is also true if the local version worked and the production version breaks.

Perhaps your server memory limit is being reached or your picture folder doesn't have write permissions.

like image 24
kevtrout Avatar answered Sep 15 '26 10:09

kevtrout



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!