Page 1 of 1

How filter particular colours on different parts of an image

Posted: Mon Nov 20, 2006 5:33 pm
by mcccy005
What I need is some sort of direction as to how to filter certain colours (eg. so an image is grey-scale; or has like a red filter so it looks substantially red or whatever).
Problem is different parts of the image require different filters.

Basically I have a calendar; and each day of the calendar could be filtered by 1 of about 7 different colours/filters.

Firstly, is there a way in HTML that I could use a particular filter on top of a cell of a HTML table so that the background image of the table still comes through, but is filtered and only filtered in that particular cell of the table??

If not; is there a way in PHP I could set coordinates of an image or something which will filter different colours??
So that from say [x][y] of the image to [x+1][y-1] would be a grey filter; and then [x+2][y] through to [x+3][y-1] would be a red filter??

Worse case scenario if this doesnt work, I can just manually capture the image behind each cell; apply a filter through adobe; and save it; and then do a bunch of 'if' statements in php to determine which cell background image (which has been manually filtered) to use.

However; the HTML idea sounds best to me (but haven't had any success in searching for the concept).

Thanks

Posted: Mon Nov 20, 2006 5:38 pm
by feyd
To maintain cross browser appearance, you really should color them with PHP choosing the correct image to display.

Posted: Tue Nov 21, 2006 12:38 am
by mcccy005
So how do I convert the region at [x][y] to [x+1][y-1] to grey-scale; and then the region from say [x+2][y-1] to [x+3][y-1] to have a blue filter over the image??

I'm not asking for all the code to do this (well...not yet anyways); but rather what tools or PHP functions are out there that will do this as I can't even find anything close to this on the internet.

There are a few things around which allow you to apply a filter to an entire image; but I need to be able to apply different filters to different parts of the image.

Cheers.

Posted: Tue Nov 21, 2006 4:14 am
by onion2k
You need to use GD if you're going to manipulate the image. Specifically the imagecolorat() and imagesetpixel() functions. Or, if the areas are nice rectangles in fixed locations, you could use imagecolorallocatealpha() and imagefilledrectangle()/imagefilledpolygon(). I wrote some hue changing code once ... it'll be in the phpgd folder somewhere.

That said though, if you're just changing the color of a cell, I'd using the background attribute of the td tag.

EDIT: viewtopic.php?t=43130&highlight=hue <- That hue changing code.