Skip to content

ext/gd: Return type violation in imagefilter when an invalid filter is provided #20070

Closed

Description

@Girgias

Description

The following code:

<?php
$image = imagecreatetruecolor(180, 30);

try {
    var_dump(imagefilter($image, -1));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}

Resulted in this output:

Fatal error: imagefilter(): Return value must be of type bool, null returned in Unknown on line 0

But I expected this output instead:

ValueError: imagefilter(): Argument #2 ($filter) must be a valid filter

Found by just staring at the code when double-checking #20066

PHP Version

latest

Operating System

No response

Activity

  1. self-assigned this
    on Oct 5, 2025
  2. added a commit that references this issue on Oct 5, 2025
    003502a
  3. added 3 commits that reference this issue on Oct 12, 2025
    26f9893
    e7aea3d
    c1d0c61
  4. added a commit that references this issue on Oct 12, 2025
    7ec9420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions