phpday 2027 - Call for Papers

imageavif

(PHP 8 >= 8.1.0)

imageavif — Invia l'immagine al browser o in un file

Descrizione

function imageavif(
    GdImage $image,
    resource|string|null $file = null,
    int $quality = -1,
    int $speed = -1
): bool

Outputs or saves a AVIF Raster image from the given image.

Elenco dei parametri

image

Un oggetto GdImage, restituito da una delle funzioni di creazione immagine, come imagecreatetruecolor().

file

Il percorso o una risorsa stream aperta (che viene chiusa automaticamente dopo il ritorno di questa funzione) in cui salvare il file. Se non è impostato o è null, il flusso raw dell'immagine verrà inviato direttamente in output.

quality

quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, larger file). If -1 is provided, the default value 52 is used.

speed

speed is optional, and ranges from 0 (slow, smaller file) to 10 (fast, larger file). If -1 is provided, the default value 6 is used.

Valori restituiti

Restituisce true in caso di successo o false in caso di fallimento.

Attenzione

Tuttavia, se libgd non riesce a produrre l'immagine, questa funzione restituisce true.

Errori/Eccezioni

Throws a ValueError if quality or speed is invalid.

Log delle modifiche

Versione Descrizione
8.4.0 Now throws a ValueError if quality or speed is invalid.

Vedere anche:

  • imagepng() - Output a PNG image to either the browser or a file
  • imagewbmp() - Invia l'immagine al browser o in un file
  • imagejpeg() - Invia l'immagine al browser o in un file
  • imagetypes() - Return the image types supported by this PHP build
+add a note

User Contributed Notes 1 note

up
1
avi at orons dot pro
4 years ago
Usage example:
$image = imagecreatefromjpeg('test.jpg');  //read a jpg file
imageavif($image, 'test.avif');  //save an avif file
To Top