imagewebp

Output a WebP image to browser or file

&reftitle.description; `bool` `imagewebp` `GdImage` `image` ``resource``string``null```file`&null; `int` `quality`-1

Outputs or saves a WebP version of the given `image`.

&reftitle.parameters;

&gd.image.description;

`file`

- &gd.image.path;

`quality`

- `quality` ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file).

&reftitle.returnvalues;

&return.success;

&gd.return.trueonerror;
&reftitle.errors;

Throws a `ValueError` if `quality` is invalid.

&reftitle.changelog;

&Version; | &Description;
8.4.0 | Now throws a `ValueError` if `quality` is invalid.
&gd.changelog.image-param;

&reftitle.examples;

### Saving an WebP file

    <?php
    // Create a blank image and add some text
    $im = imagecreatetruecolor(120, 20);
    $text_color = imagecolorallocate($im, 233, 14, 91);

    imagestring($im, 1, 5, 5,  'WebP with PHP', $text_color);

    // Save the image
    imagewebp($im, 'php.webp');

    // Free up memory
    imagedestroy($im);
    ?>