intervention imageで画像にテキストを載せたいと思っていますが、"Call to undefined function Intervention\Image\Gd\imagettftext()"のエラーが出てしまいます。
gdライブラリも調べて見ましたが、なぜエラーが出るのかよく分かりませんでした。
フォントはpublic/fonts直下にあり、SawarabiGothic-Regular.ttfです。
コントローラー
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Intervention\Image\ImageManagerStatic as Image; use App\Post; class PostController extends Controller { public function index(){ $image=Post::all(); return view('index',compact('image')); } public function store(Request $request){ $request->validate([ 'image'=>'required|image|mimes:jpg,jpeg,png|max:2000' ]); $file=$request->file('image'); $fileName=str_random(20).'.'.$file->getClientOriginalExtension(); $img=Image::make($file); $img->text("Hellow World!!", 70, 70,function($font){ $font->file('fonts/SawarabiGothic-Regular.ttf'); $font->size(200); }); Image::make($img)->save(public_path('images/'.$fileName)); $post=new Post; $post->image=$fileName; $post->save(); return redirect()->back(); } }
