...

View Full Version : Warning: imagefilter() expects parameter 2 to be long, string given



docock
06-17-2010, 02:19 PM
I'm using this code to put a filter on an image:



$filter="pixelate";
if ($filter == 'negative')
imagefilter($img,IMG_FILTER_NEGATE);
else
if ($filter == 'grayscale')
imagefilter($img,IMG_FILTER_GRAYSCALE);
else
if ($filter == 'brightness')
imagefilter($img,IMG_FILTER_BRIGHTNESS, $_REQUEST['arg1']);
else
if ($filter == 'contrast')
imagefilter($img,IMG_FILTER_CONTRAST, $_REQUEST['arg1']);
else
if ($filter == 'colorize')
imagefilter($img,IMG_FILTER_COLORIZE, $_REQUEST['arg1'], $_REQUEST['arg2'], $_REQUEST['arg3']);
else
if ($filter == 'edgedetect')
imagefilter($img,IMG_FILTER_EDGEDETECT);
else
if ($filter == 'emboss')
imagefilter($img,IMG_FILTER_EMBOSS);
else
if ($filter == 'gaussian_blur')
imagefilter($img,IMG_FILTER_GAUSSIAN_BLUR);
else
if ($filter == 'selective_blur')
imagefilter($img,IMG_FILTER_SELECTIVE_BLUR);
else
if ($filter == 'mean_removal')
imagefilter($img,IMG_FILTER_MEAN_REMOVAL);
else
if ($filter == 'pixelate')
imagefilter($img, IMG_FILTER_PIXELATE, 3, true);
else
if ($filter == 'smooth')
imagefilter($img,IMG_FILTER_SMOOTH, $_REQUEST['arg1']);
imagepng($img);
imagedestroy($img);

They all work fine, except the pixelate function, it's giving me:
Warning: imagefilter() expects parameter 2 to be long, string given
How can I alter the coding so that it will work?

abduraooft
06-17-2010, 02:45 PM
Which is your PHP version? Have you checked the "Changelog" at http://php.net/imagefilter

docock
06-17-2010, 03:14 PM
:S I've got version 5.2

Thanks for replying

Fou-Lu
06-17-2010, 04:20 PM
You may have missed what abduraooft was indicating:


Changelog
Version Description
5.3.0 Pixelation support (IMG_FILTER_PIXELATE) was added.
5.2.5 Alpha support for IMG_FILTER_COLORIZE was added.

IMG_FILTER_PIXELATE is not available for you to use, and IMG_FILTER_COLORIZE *may* be available depending on your revision (you only have 5.2 here, you need 5.2.5 to use IMG_FILTER_COLORIZE).
Since none of these exist, PHP's default fallback on undefined constants is to treat them as strings. This is why you are getting the error; IMG_FILTER_PIXELATE is interpreted as 'IMG_FILTER_PIXELATE' instead of as its intended integer value.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum