Skip to content

imagewebp() returns true when encoding fails #24457

Open

Description

@lacatoire

Description

The following code:

$im = imagecreate(4, 4);
var_dump(imagewebp($im, 'out.webp'));

Resulted in this output:

Warning: imagewebp(): Palette image not supported by webp
bool(true)

(out.webp is empty.)

But I expected this output instead:

Warning: imagewebp(): Palette image not supported by webp
bool(false)

The same happens when libwebp rejects the image, e.g. imagecreatetruecolor(16384, 1): a warning, then true. This comes from gdImageWebpCtx() returning void.

PHP Version

PHP 8.5.13-dev (cli)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions