0

我在访问此 API 时遇到问题。你能帮我看看我哪里错了吗?

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

错误是:

[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
4

2 回答 2

0

这可能是您包含的lib的路径问题,您还需要提供您得到的确切错误,如果您使用的是ubuntu服务器,您可以通过命令检查错误日志.....

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

这将向您显示代码中的确切错误。

于 2018-07-26T16:10:36.550 回答
0

在您提供的错误中,有一个Gd not installed.

所以你需要设置它并启用它。

类似于:在 Ubuntu / debian 上

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

在 Centos/Fedora 上

# dnf install php-gd
# phpenmod gd
于 2018-07-28T17:05:57.120 回答