473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

changing image colors

Hi folks,

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

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
it.

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

Thank you,

Michel
Jul 17 '05 #1
7 2507
I noticed that Message-ID: <d9**********@news.cistron.nl> from Michel
contained the following:
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
it.

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


Flash?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2
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.

~D

Jul 17 '05 #3
Okay.... I need 65000 variations, premade....
So a script that wanders through the colors and changes a template and saves
it.
That would be ideal.....
"dracolytch" <dr********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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.

~D

Jul 17 '05 #4
On Fri, 24 Jun 2005 16:22:52 +0200, "Michel" <no@spam.please> wrote:
I wonder if what I have in mind is possible, maybe even not all that
complicated:

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
it.

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


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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>circle</title>
</head>
<body>
<?php
$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'>
</form>

</body>
</html>
image.php :

<?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');
imagepng($im);
?>

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.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #5
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?

Thanks,

MIchel

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:c3********************************@4ax.com...
On Fri, 24 Jun 2005 16:22:52 +0200, "Michel" <no@spam.please> wrote:
I wonder if what I have in mind is possible, maybe even not all that
complicated:

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 processit.

Is this at all possible and could someone point me in the right direction ora script that does this?
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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>circle</title>
</head>
<body>
<?php
$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'>
</form>

</body>
</html>
image.php :

<?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');
imagepng($im);
?>

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.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Jul 17 '05 #6
On Sat, 25 Jun 2005 15:49:08 +0200, "Michel" <no@spam.please> wrote:
Is it possible to change the color of an existing image too?


If you've got a paletted image, then:

http://uk2.php.net/manual/en/function.imagecolorset.php

Otherwise:

http://uk2.php.net/manual/en/function.imagefill.php

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #7
Great stuff..... now it's back to the drawing board for me. Lemmie
experiment with that for a while.

Many thanks!

Michel

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:ne********************************@4ax.com...
On Sat, 25 Jun 2005 15:49:08 +0200, "Michel" <no@spam.please> wrote:
Is it possible to change the color of an existing image too?


If you've got a paletted image, then:

http://uk2.php.net/manual/en/function.imagecolorset.php

Otherwise:

http://uk2.php.net/manual/en/function.imagefill.php

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Laszlo Zsolt Nagy | last post by:
Hello, How can I determine the number of colors used in an image? I tried to search on Google but I could figure out. I read the PIL handbook but I do not see how to do it. Can anyone help? ...
3
by: Mr. x | last post by:
Hello, I would like that my image's background color will be transparent. What I have is only paintbrush. My image is *.jpg format (I have tried to save it as *.gif format, and I got less...
0
by: bearophileHUGS | last post by:
Hello, this time I have a question about PIL usage, maybe if Lundh has some time he can answer me. I am experimenting different color quantization algorithms, so having computed the palette with a...
4
by: Jmc | last post by:
Hi Need some advice on how to get all colors in an image. I wish to have an input file, in my case it will be a scanned piece of fabric. I would like to first of all gen an array with all the...
1
by: jitu78 | last post by:
GIF Images Use GIF files for images that have a small number of colors. GIF files are always reduced to no more than 256 unique colors. The compression algorithm for GIF files is less complex than...
7
by: Cate Archer | last post by:
I want to have a border around an image that changes color when the mouse hovers over it. The following code works perfectly in FireFox but not in Internet Exploiter. The text link changes color...
1
by: oruccim | last post by:
hi I want understanding pictures colorfull for examle colorfull or black-white image.google.com there are understand it .Can I understand it thanks....
7
by: mishrarajesh44 | last post by:
hii all Truly telling i hav got this code from net & i am finding error while running the code below.. code:- <?php $idir = "photo/"; // Path To Images Directory $tdir =...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.