Jordan Gomila wrote:
Thanks, but I am not trying to change width and
heigth. I am changing pixel color.
I have done it with a java applet but I wish to
allow to load images from web, and as it is not
allowed with untrusted applets I amb looking for
other alternatives.
Client side javascript actually can't *change* image properties. It can
only affect the way they are shown on the user's screen, which is a
significant difference.
It's not very clear to me what you mean by "changing pixel color".
There are some CSS/javascript possibilities that you could use/combine
to alter the image's appearance.
Maybe this could be a start:
<html>
<head>
<style>
div { width:200px;hei ght:200px;backg round-color: white; }
</style>
<script language="javas cript">
function alterpic(o,c)
{
if (document.image s) {
document.getEle mentById("back" ).style.backgro undColor=c;
document.images["sImg"].style.filter = "alpha(opacity= "+o+")";
document.images["sImg"].style.MozOpaci ty=o/100;
}
}
</script>
</head>
<body bgcolor="white" >
<p>
<div id="back" name="back"><im g name="sImg"
src="http://groups.google.b e/img/watched_y.gif"
width="200" height="200"></div>
</p>
<p>
<input type="button"
onClick="alterp ic('30','red')" value="Version 1">
<input type="button"
onClick="alterp ic('80','blue') " value="Version 2">
<input type="button"
onClick="alterp ic('40','green' )" value="Version 3">
<input type="button"
onClick="alterp ic('100','white ')" value="Original ">
</p>
</body>
</html>
Please note that you're on sensitive grounds here when it comes to
browser compatibility. I tested the code on latest IE and NS versions -
should be no problem there.
If you want to actually change your image, you should use a server side
approach. E.g. PHP/CGI with a call to GD/ImageMagick on Unix based
operating systems.
--
Bart