473,748 Members | 7,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2532
I noticed that Message-ID: <d9**********@n ews.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********@gma il.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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&a mp;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 = imagecoloralloc ate($im, 255, 255, 255);

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

$fill = imagecoloralloc ate($im, $r, $g, $b);

imagefilledelli pse($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.andyhsoftwa re.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.c om...
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&a mp;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 = imagecoloralloc ate($im, 255, 255, 255);

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

$fill = imagecoloralloc ate($im, $r, $g, $b);

imagefilledelli pse($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.andyhsoftwa re.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.andyhsoftwa re.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.c om...
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.andyhsoftwa re.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
2900
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? -- Best regards, Laszlo
3
3869
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 quality), and I don't know how to make the background. In every tool I open the image (html, flash, etc...) I see the original background color, and not the transparent color.
0
1747
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 clustering function, I use the code below to quantize the original image to produce an image without dithering (so I can see better the quantization results). I have seen that the *standard* distance function I use isn't standard enough,...
4
3944
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 colors represented in the image. and an percentage of how much the color exists. Lets assume that the color of the fabric is blue, it will probably have pixels that are not #0000FF since the diferent threads in the fabric
1
1591
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 for JPEG files, but when used on flat color images and text it produces very small file sizes. The GIF format is not suitable for photographic images or images with gradient colors. Because the GIF format has a limited number of colors, gradients...
7
17276
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 but the image link stays the same. Anybody know how I can make it work in IE? I saw a web site where the guy got it to work in both browsers. <html> <head> <title>TEST</title>
1
1945
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
17058
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 = "photo/thumbs/"; // Path To Thumbnails Directory $twidth = "125"; // Maximum Width For Thumbnail Images
10
7071
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 only small sized iamages.. for eg. resizing takes place for 70 kb sized images but fails for 600kb or more.. my code is below..
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4606
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.