Jump to content

Change Colour Of An Image Dynamically


johnsmith153

Recommended Posts

I am not sure really where to start with this.

 

Title explains, but it is not just by change the .gif that is showed using a javascript link or something. This is much bigger.

 

Imagine a .png that simply has a circle on it - drawn however, vector etc.

 

Based on the #RRGGBB colour value that is returned from the database, I would like the circle to show that colour.

 

I have done something like this with Flash - but I dont really want to use Flash for this.

 

I suppose a CSS div and setting the background, but I doubt you can get the shape I need.

 

If it matters, the shape is actually a very basic football (soccer) shirt image, and the colour would represent the shirt colour.

Link to comment
Share on other sites

Sorry about delay, messing around with trying to find where I can get some public space to give you the image.

 

I can't upload a .eps here apparently, so I have put it here:

http://rapidshare.com/files/152827746/268552_illustration.eps.html

It is free to download once you get past all the crap.

 

It's nothing special - just really an outline. But as you can see ideally the colour would just be inside the shirt.

Link to comment
Share on other sites

The best I can think of is to save that shirt image as png and make everything that is white in that pic transparent 100% so that all you have is the outline of the shirt.  Then have a div with your specified color background and put the png on top of it.

Link to comment
Share on other sites

If this is going to be a for sale item (a t-shirt), you will probably have only certain available colors anyway... or more colors people would wear..  If it's not too many, save the images of the different color combos and swap out the images with javascript when they choose a color.

Link to comment
Share on other sites

xtropolis,

No, this is no dodgy cheap t-shirt sale. This is part of an application where a user chooses from a range of colours - like on http://www.colorpicker.com/ - they choose any colour, and it appears as I mentioned.

 

CroNiX,

Am I right though that this would just be a square block of colour with the outline inside, as opposed to the outline with the colour inside?

 

Although maybe the image could be a a square block on a coloured div, with juist the transparent "inside" the shirt outline transparent - is that what you meant?

 

I'll give it a go.

Link to comment
Share on other sites

Either way...actually I just tested it.  I was in AI and just saved for web and devices as a gif with transparency.  It actually turned out really well I didn't even consider gif.  Then I just put it in a div and set the background color to various colors.  The gif turned out to be 4.5k in size and used 17 colors (16 + transparent).

Link to comment
Share on other sites

I've just put it all together and got a problem. I have set the div and image to the same size, yet I think it is the image that appends whitespace after and below, so my background colour creeps through and I have a line of colour bottom and right of the image.

 

Did you manage to avoid this CroNiX?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.