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

imagecreatefromavif

Description

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

Syntax

imagecreatefromavif(
    string $filename
): GdImage|false

Parameters

filename

Path to the AVIF raster image.

Return

Returns an image object on success, false on errors.

Examples

1 · return

<?

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

$return = imagecreatefromavif($filename);

var_dump($return);

?>
bool(false)

2 · base64

<?

$filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/avif/1.avif';
$image = imagecreatefromavif($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>';

?>
HomeMenu