It's the Imagefilter function itself complaining, not PHP croaking about argument count or value:
$image = imagecreatefrompng('filter.png');
$list_effects = array(
"NEGATE" => IMG_FILTER_NEGATE,
"GRAYSCALE" => IMG_FILTER_GRAYSCALE,
"BRIGHTNESS" => IMG_FILTER_BRIGHTNESS,
"CONTRAST" => IMG_FILTER_CONTRAST,
"COLORIZE" => IMG_FILTER_COLORIZE,
"EDGEDETECT" => IMG_FILTER_EDGEDETECT,
"EMBOSS" => IMG_FILTER_EMBOSS,
"SMOOTH" => IMG_FILTER_SMOOTH,
"MEAN_REMOVAL" => IMG_FILTER_MEAN_REMOVAL
);
foreach ($list_effects as $name => $effect)
{
echo "$name<br>";
imagefilter($image, $effect, NULL, NULL, NULL); // <-- passing NULL is OK
output:
NEGATE
GRAYSCALE
BRIGHTNESS // <-- argument count is a problem for 3 of the primitives
Warning: imagefilter() expects exactly 3 parameters, 5 given in ...
CONTRAST
Warning: imagefilter() expects exactly 3 parameters, 5 given in ...
COLORIZE
EDGEDETECT
EMBOSS
SMOOTH
Warning: imagefilter() expects exactly 3 parameters, 5 given in ...
MEAN_REMOVAL
BRIGHTNESS, CONTRAST and SMOOTH are the culprits.
Now instead of checking all parameters, you could do something like that:
switch (func_num_args())
{
case 3: imagefilter($img,$filter); break;
case 4: imagefilter($img,$filter,$arg1); break;
case 5: imagefilter($img,$filter,$arg1,$arg2); break;
case 6: imagefilter($img,$filter,$arg1,$arg2,$arg3); break;
}
or if you feel lucky (since only the functions with 1 parameter complain)
if (func_num_args() == 4) imagefilter($img,$filter,$arg1);
else imagefilter($img,$filter,$arg1,$arg2,$arg3);
Of course this is risky, since a newer version of PHP could perform more thorough checks and give off new warnings for filters with 0 or 2 parameters.