Internal Error while I am accessing image using imagine

1.2k Views Asked by At

I am facing issue while accessing this API. Can you please help me where I am wrong?

public function index()
{

    require_once('./application/libraries/imagine_autoloader.php');

    $imagine = new \Imagine\Gd\Imagine();

    $image = $imagine->open('assets/a1.jpg'); /**Getting error here */


    $thumbnail = $image->thumbnail(new Imagine\Image\Box(100, 100));
    $thumbnail->save('assets/thumnail_image1.jpg');
    $this->load->view('welcome_message');
}

The error is:

[Thu Jul 26 12:13:24.313248 2018] [:error] [pid 1898] [client 172.17.3.63:53787] PHP Fatal error:  Uncaught exception 'Imagine\\Exception\\RuntimeException' with message 'Gd not installed' in /var/www/html/CodeIgniter-2.2.6/application/libraries/Imagine/Gd/Imagine.php:172
Stack trace:
#0 /var/www/html/CodeIgniter-2.2.6/application/libraries/Imagine/Gd/Imagine.php(39): Imagine\\Gd\\Imagine->loadGdInfo()
#1 /var/www/html/CodeIgniter-2.2.6/application/controllers/welcome.php(25): Imagine\\Gd\\Imagine->__construct()
#2 [internal function]: Welcome->index()
#3 /var/www/html/CodeIgniter-2.2.6/system/core/CodeIgniter.php(360): call_user_func_array(Array, Array)
#4 /var/www/html/CodeIgniter-2.2.6/index.php(202): require_once('/var/www/html/C...')
#5 {main}
thrown in /var/www/html/CodeIgniter-2.2.6/application/libraries/Imagine/Gd/Imagine.php on line 172
2

There are 2 best solutions below

0
On

On the error you provide, there is a Gd not installed.

So you need to set it up and enable it.

Something like: on Ubuntu / debian

# apt-get install php7.0-gd
# phpenmod gd

on Centos/Fedora

# dnf install php-gd
# phpenmod gd
0
On

It could be the path issue of lib you have included, Also you need to provide exact error you getting, if you are using ubuntu server you can check error log via command.....

tail -f /var/log/apache2/error.log

this will show you the exact error in your code.