assign filter to png with javascript

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

assign filter to png with javascript

Post 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)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

you mean with gd or something?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

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

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