Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-17-2010, 01:19 PM   PM User | #1
docock
Regular Coder

 
Join Date: Feb 2007
Posts: 195
Thanks: 20
Thanked 1 Time in 1 Post
docock is an unknown quantity at this point
Warning: imagefilter() expects parameter 2 to be long, string given

I'm using this code to put a filter on an image:

Quote:
$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?
docock is offline   Reply With Quote
Old 06-17-2010, 01:45 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Which is your PHP version? Have you checked the "Changelog" at http://php.net/imagefilter
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 06-17-2010, 02:14 PM   PM User | #3
docock
Regular Coder

 
Join Date: Feb 2007
Posts: 195
Thanks: 20
Thanked 1 Time in 1 Post
docock is an unknown quantity at this point
:S I've got version 5.2

Thanks for replying
docock is offline   Reply With Quote
Old 06-17-2010, 03:20 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You may have missed what abduraooft was indicating:
Quote:
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09 AM.


Advertisement
Log in to turn off these ads.