rosell-dk/webp-convert

Converting time takes too long

devenairevo opened this issue · 1 comments

Guys, when trying to upload 5 mb jpeg, then it takes too long for converting. What kind of issue it could be? Here is my class for converting.

class ImageConverter
{

    /**
     * @throws ConversionFailedException
     */
    public function convertImage($file, string $generatedName, string $folderName): void
    {
        $uploadPath = Yii::getAlias('@common/web/uploads/') . $folderName . '/';

        WebPConvert::convert($file->tempName, $uploadPath . $generatedName, $this->getConvertOptions());

    }

    public static function getConvertOptions(): array
    {
        return [
            'png' => [
                'encoding' => 'auto',
                'near-lossless' => 60,
                'quality' => 80,
                'sharp-yuv' => true,
            ],
            'jpeg' => [
                'encoding' => 'auto',
                'quality' => 80,
                'sharp-yuv' => true,
            ],
            'jfif' => [
                'encoding' => 'auto',
                'quality' => 80,
                'sharp-yuv' => true,
            ]
        ];
    }
}

Fixed by using Gd::convert instead of WebConverter::convert