Page 1 of 1
assign filter to png with javascript
Posted: Wed Dec 06, 2006 7:16 pm
by Luke
is there a way to assign a filter or something to a png image with javascript? I have a bunch of icons that need to be different colors depending on a value in the database and it would be so easy if I could just change their color with javascript (requiring js is ok on this particular site since it's in-house)
Posted: Wed Dec 06, 2006 7:22 pm
by John Cartwright
I doubt it, although you could dynanamically generate the icons with different color. Still, whats wrong with just serving different images depending on the value?
Edit | This may be of interest
http://www.dynamicdrive.com/forums/showthread.php?t=948
Posted: Thu Dec 07, 2006 10:12 am
by Luke
Well, I can serve different images, it would just be easy if they were dynamically colored, but that's ok.. it's just kind of a lot of icons I have to create but that's life.
Posted: Thu Dec 07, 2006 10:27 am
by John Cartwright
The Ninja Space Goat wrote:Well, I can serve different images, it would just be easy if they were dynamically colored, but that's ok.. it's just kind of a lot of icons I have to create but that's life.
Why not dynamically generate them if you have a large base. Have one standard icon, and change the hue depending on which variable you call.
Code: Select all
<img src="/icon.php?id=4&color=red" alt="im an icon" />
You'll be generating more http requests, so weigh the pros and cons accordingly.
Posted: Thu Dec 07, 2006 11:05 am
by Luke
you mean with gd or something?
Posted: Thu Dec 07, 2006 12:11 pm
by feyd
You shouldn't rely on Javascript being able to do it unless you do some serious amount of work, so I'd go with GD if you can't precalculate.
Posted: Thu Dec 07, 2006 12:23 pm
by Luke
thanks guys... I'll give gd a try. This will be my first time using it... I've been meaning to try it out, but never have.
Posted: Thu Dec 07, 2006 12:26 pm
by feyd
The Ninja Space Goat wrote:thanks guys... I'll give gd a try. This will be my first time using it... I've been meaning to try it out, but never have.
An even better reason to get into it.
