How filter particular colours on different parts of an image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mcccy005
Forum Contributor
Posts: 123
Joined: Sun May 28, 2006 7:08 pm

How filter particular colours on different parts of an image

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

To maintain cross browser appearance, you really should color them with PHP choosing the correct image to display.
mcccy005
Forum Contributor
Posts: 123
Joined: Sun May 28, 2006 7:08 pm

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
Post Reply