Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

imagecreatefromwebp

Description

The imagecreatefromwebp of Image for PHP create a new image from file or URL.

Syntax

imagecreatefromwebp(
    string $filename
): GdImage|false

Parameters

filename

Path to the WebP image.

Return

Returns an image object on success, false on errors.

Examples

1 · return

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/webp/1.webp';

$return = imagecreatefromwebp($filename);

var_dump($return);

?>
object(GdImage)#1 (0) {
}

2 · base64

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/webp/1.webp';
$image = imagecreatefromwebp($filename);

ob_start();

    imagepng($image);

$output = ob_get_clean();

echo '<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,' . base64_encode($output) . '">
</body>
</html>';

?>
<!doctype html>
<html>
<body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABAElEQVR4nO3RQQ0AIBDAsAP/nuGNAvZoFSzZmpkzZOzfAbwMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEkxpAYQ2IMiTEk5gLcywHHnWLL6AAAAABJRU5ErkJggg==">
</body>
</html>
HomeMenu