在 laravel 6 中将图像转换为 png

问题描述 投票:0回答:0

我正在使用 laravel 6 ( php7.3 ),当客户上传一张 webp 格式的照片时,它给出了一个错误: “不支持的图像类型。GD 驱动程序只能解码 JPG、PNG、GIF 或 WebP 文件。” 现在我想在上传过程中将格式更改为 png。我怎样才能做到这一点? 谁能帮帮我! 这是我的代码:

$avatar = $request->file('thumb');
$filename = time() . '.' . $avatar->getClientOriginalExtension();

$path = public_path('/store/products/' . $filename);
Image::make($avatar)->encode('jpg')
    ->text($store['watermark_text'], 80, 40, function ($font) {
        $font->size(35);
        $font->color($_POST['colorr']);
        $font->align('left');
        $font->valign('bottom');
        $font->angle(90);
    })
    ->save(public_path('/store/products/' . $filename));


$article = Product::where('id', '=', $id)->first();
$article->thumb2 = $filename;
$article->save();
php laravel intervention
© www.soinside.com 2019 - 2024. All rights reserved.