我收到此错误消息:
Call to undefined function Intervention\\Image\\Gd\\imagecreatefromjpeg()
这是我的php信息:
我正在使用laravel框架(版本5.6)和php 7.1。
我想上传图片,但出现此错误。
gd
GD Support enabled
GD Version bundled (2.1.0 compatible)
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.6.32
WBMP Support enabled
XBM Support
我的商店功能:
public function store(CompanyRequest $request)
{
$all = $request->except(['category-company', 'flag', 'null', 'file', 'producer-company','manager','address','description','phone']);
$flag = array_values($request->input('flag'));
$jsonFlag = json_encode($flag);
$all['flag'] = $jsonFlag;
if($request->input('manager')){
$all['manager']=$request->input('manager');
}
if($request->input('address')){
$all['address']=$request->input('address');
}
if($request->input('description')){
$all['description']=$request->input('description');
}
if($request->input('phone')){
$all['phone']=$request->input('phone');
}
$file = $request->file('file');
$name = $file->getClientOriginalName();
$dir = '/img/company/';
$path = $dir . time() . $name;
$thumbnail = $dir . 'tn-' . time() . $name;
$all['path'] = $path;
$all['thumbnail'] = $thumbnail;
$company = Company::create($all);
$file->move('img/company', time() . $name);
$img = Image::make('img/company/' . time() . $name);
$img->resize(100, 100);
$img->save('img/company/tn-' . time() . $name);
$company->categories()->sync($request->input('category-company'));
$company->producers()->sync($request->input('producer-company'));
return Response::json($company);
}
答案 0 :(得分:1)
我有同样的问题。我花了几个小时才能到达这里,因为the Image Intervention code uses:
$core = @imagecreatefromjpeg($path);
因此可以减少错误。 Apache抛出了500条响应,但没有任何关于原因的消息,没有日志,什么也没有。非常令人沮丧!
线索位于您上面包含的GD支持输出中,该输出未列出JPG。我的是一样的:
php -r 'print_r(gd_info());'
Array
(
[GD Version] => bundled (2.1.0 compatible)
[FreeType Support] =>
[T1Lib Support] =>
[GIF Read Support] => 1
[GIF Create Support] => 1
[JPEG Support] =>
[PNG Support] => 1
[WBMP Support] => 1
[XPM Support] =>
[XBM Support] => 1
[WebP Support] =>
[JIS-mapped Japanese Font Support] =>
)
我正在Docker容器中运行PHP / Apache,对我来说,解决方案是在Dockerfile中添加JPG支持,如in the 'PHP Core Extensions' section of the repo所述。现在GD显示了JPG支持:
php -r 'print_r(gd_info());'
Array
(
[GD Version] => bundled (2.1.0 compatible)
[FreeType Support] => 1
[FreeType Linkage] => with freetype
[T1Lib Support] =>
[GIF Read Support] => 1
[GIF Create Support] => 1
[JPEG Support] => 1
[PNG Support] => 1
[WBMP Support] => 1
[XPM Support] =>
[XBM Support] => 1
[WebP Support] =>
[JIS-mapped Japanese Font Support] =>
)
图像干预最终成功成功!