How To Convert WebP To JPG Image Format In PHP With Example?

function yttags_webp2jpg($src_file_path, $file_destination_path, $compression_qty = 100)
{
    $image = imagecreatefromwebp($src_file_path);
    $final_output = imagejpeg($image, $file_destination_path, $compression_qty);
    if (false === $final_output) {
        return false;
    }
    imagedestroy($image);
    return $file_destination_path;
}

Function usage:

echo yttags_webp2jpg('img/oldfile.webp','img/newfile.jpg',100);

Leave a Comment