我在 Laravel5 中使用干预包在图像中插入文本,它运行良好。但是如果我添加 font(.ttf) 它会显示以下错误。目录正确。
NotSupportedException in Font.php line 30: Internal GD font () not available. Use only 1-5.
$image = Image::make(public_path('/userimage/') . "user.png");
$image->text('text string', 10, 5, function($font) {
$font->file(asset('/web/fonts/OpenSans-Regular.ttf'));
$font->size(50);
$font->color('#fdf6e3');
$font->angle(45);
});
最佳答案
GD 库不支持自定义字体。你应该使用 Imagick。转到 config/image.php 并将 driver 值编辑为 'imagick'(在您实际为其安装扩展之后):
'司机'=> '想象'
asset('/web/fonts/OpenSans-Regular.ttf')
返回一个 URL。你必须提供一个路径。请改用public_path('web/fonts/OpenSans-Regular.ttf')
。
关于image - Laravel 干预图像添加带有字体的文本显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36173360/