changing image colors

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi folks,

I wonder if what I have in mind is possible, maybe even not all that

I have an image, which is a yellow circle. I want this yellow circle to
change color by having 3 sliders (RGB) on a website and a button to process

Is this at all possible and could someone point me in the right direction or
a script that does this?

Thank you,


Re: changing image colors

contained the following:

Quoted text here. Click to load it


Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: changing image colors

Flash is one solution... From an interface perspective, probably the
best. Not everyone has the cash for a copy of flash though.

Here's another one which will at first seem backward, but is nice and
sneaky, and doesn't require flash:

Make a table, and put in it a transparent gif.  The gif is actually
white with a transparent circle in the middle.

Make the background color of the table yellow.

Use whatever input you find convenient to create controls that, using
JavaScript, change the background color of the table.


Re: changing image colors

Okay.... I need 65000 variations, premade....
So a script that wanders through the colors and changes a template and saves
That would be ideal.....

Quoted text here. Click to load it

Re: changing image colors

Quoted text here. Click to load it

 Depends when you want the image to change. The PHP answer is that you have to
submit the form back to PHP each time you want the image to change, so PHP can
regenerate it and send it back.

 Another snag is that HTML forms don't include slider controls, so you'd have
to have something else like a series of radio buttons or an input box with a
number in it.

 circle.php :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
" ">
$r = isset($_GET['r']) ? (int)$_GET['r'] : 255;
$g = isset($_GET['g']) ? (int)$_GET['g'] : 255;
$b = isset($_GET['b']) ? (int)$_GET['b'] : 0;
print "<img src='image.php?r=$r&amp;g=$g&amp;b=$b' alt=''>";

<form method='get' action='circle.php'>
 R<input type='text' name='r' value='<?php print $r; ?>' size='3'>
 G<input type='text' name='g' value='<?php print $g; ?>' size='3'>
 B<input type='text' name='b' value='<?php print $b; ?>' size='3'>
 <input type='submit' value='process'>


 image.php :

$im = imagecreate(96, 96);
$white = imagecolorallocate($im, 255, 255, 255);

$r = (int)$_GET['r'];
$g = (int)$_GET['g'];
$b = (int)$_GET['b'];

$fill  = imagecolorallocate($im, $r, $g, $b);

imagefilledellipse($im, 48, 48, 96, 96, $fill);

header('Content-type: image/png');

 Another approach could be Javascript based, changing the src attribute of an
<img> tag in response to user input to call a PHP script with parameters
controlling the image colour.

< Space: disk usage analysis tool

Re: changing image colors

Hi Andy,

Great help this is indeed....
But... this creates a new image.
Is it possible to change the color of an existing image too?



Quoted text here. Click to load it
have to

Re: changing image colors

Quoted text here. Click to load it

 If you've got a paletted image, then:


< Space: disk usage analysis tool

Re: changing image colors

Great stuff..... now it's back to the drawing board for me. Lemmie
experiment with that for a while.

Many thanks!


Quoted text here. Click to load it

Site Timeline