0

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
wargre
  • 4,575
  • 1
  • 19
  • 35
Umashankar
  • 694
  • 7
  • 21
  • 1
    A 500 error is a generic error message and covers pretty much every single thing that can go wrong with a script. Check your server error logs to find out the exact error message. – aynber Jul 26 '18 at 16:02

2 Answers2

0

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.

piyush
  • 655
  • 4
  • 11
0

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
wargre
  • 4,575
  • 1
  • 19
  • 35