访问此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
答案 0 :(得分:0)
这可能是您所包含的lib的路径问题,另外,您还需要提供所得到的确切错误,如果您使用的是ubuntu服务器,则可以通过命令检查错误日志。...
tail -f /var/log/apache2/error.log
这将向您显示代码中的确切错误。
答案 1 :(得分:0)
在您提供的错误中,有一个Gd not installed
。
所以您需要设置并启用它。
类似: 在Ubuntu / debian上
# apt-get install php7.0-gd
# phpenmod gd
在Centos / Fedora上
# dnf install php-gd
# phpenmod gd