Hi there,
I want to show a simple image on a web page, and allow the viewer to
select and change one of the colours used in the image, and immediately
preview the result. I'd like to keep the image processing away from the
server to make the colour selection/preview process quicker, and I also
don't want to pre-generate all possible images as there are too many
colours that can be selected.
Does JS (or any JS libraries) provide image manipulation capabilities
where I can search & replace a colour in an image or a portion of the
image?
Thanks,
Stan 10 3455
Pulzar wrote: I want to show a simple image on a web page, ...
<snip> Does JS (or any JS libraries) provide image manipulation capabilities where I can search & replace a colour in an image or a portion of the image?
You will not be able to do that in a web browser over the Internet.
Richard.
Pulzar wrote: Does JS (or any JS libraries) provide image manipulation capabilities where I can search & replace a colour in an image or a portion of the image?
There is a specification as part of the canvas element and its two
dimensional graphics context:
<http://whatwg.org/specs/web-apps/current-work/#pixel>
but it looks to me as if neither Firefox 1.5 nor Opera 9 on their canvas
implementation support that getImageData method.
Safari also has canvas support but I can't test now whether it supports
getImageData.
--
Martin Honnen http://JavaScript.FAQTs.com/
Pulzar wrote: Does JS (or any JS libraries) provide image manipulation capabilities where I can search & replace a colour in an image or a portion of the image?
You may be able to convert the image into an svg file, on the
server-side, then manipulate the svg file.
Manipulating the image on the server should be a quick operation, as
libgd is fast.
Richard Cornford wrote: Pulzar wrote: I want to show a simple image on a web page, ... <snip> Does JS (or any JS libraries) provide image manipulation capabilities where I can search & replace a colour in an image or a portion of the image? You will not be able to do that in a web browser over the Internet.
Sure he could. It might require a specific browser like IE and an ActiveX
control, but that can certainly be done in a web browser over the Internet.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
Matt Kruse wrote: Sure he could. It might require a specific browser like IE and an ActiveX control, but that can certainly be done in a web browser over the Internet.
If the server knows which image the browser has, then all it needs to
know is which color to replace by another color, and then just tell the
client to reget the image.
It shouldn't require anything that is browser specific.
James Black wrote: Matt Kruse wrote: Sure he could. It might require a specific browser like IE and an ActiveX control, but that can certainly be done in a web browser over the Internet.
If the server knows which image the browser has, then all it needs to know is which color to replace by another color, and then just tell the client to reget the image.
It shouldn't require anything that is browser specific.
....or write an Java Applet that does it...
--
Dag.
James Black wrote: [...] You may be able to convert the image into an svg file, on the server-side, then manipulate the svg file.
Manipulating the image on the server should be a quick operation, as libgd is fast.
Actually, no - image manipulating is among the worst CPU culprits on a
machine.
--
Bart
Pulzar wrote: Hi there,
I want to show a simple image on a web page, and allow the viewer to select and change one of the colours used in the image, and immediately preview the result. I'd like to keep the image processing away from the server to make the colour selection/preview process quicker, and I also don't want to pre-generate all possible images as there are too many colours that can be selected.
Does JS (or any JS libraries) provide image manipulation capabilities where I can search & replace a colour in an image or a portion of the image?
You won't be able to alter the image in Javascript, but you can achieve
what you want with a little lateral thinking.
Make your image a PNG with an alpha channel that masks out the colour
you want to change and use CSS to give the image's container a solid
colour background. If the colour is just a solid colour and doesn't
need mixing with the image, you could use a GIF instead and not have to
bother with the CSS hacks to get IE to display alpha channelled PNGs
properly.
Now use JS to change the colour of the CSS background.
n...@chthonic.f9.co.uk wrote: [...] You won't be able to alter the image in Javascript, but you can achieve what you want with a little lateral thinking.
Make your image a PNG with an alpha channel that masks out the colour you want to change and use CSS to give the image's container a solid colour background. If the colour is just a solid colour and doesn't need mixing with the image, you could use a GIF instead and not have to bother with the CSS hacks to get IE to display alpha channelled PNGs properly.
Now use JS to change the colour of the CSS background.
Indeed, also see http://tinyurl.com/hkvrz
for some ideas that might help...
--
Bart
Martin Honnen wrote: There is a specification as part of the canvas element and its two dimensional graphics context: <http://whatwg.org/specs/web-apps/current-work/#pixel> but it looks to me as if neither Firefox 1.5 nor Opera 9 on their canvas implementation support that getImageData method.
But Opera 9 implements a special canvas graphics context that allows
pixel wise manipulation of images on the client, see
<http://oxine.opera.com/gallery/canvas/2dgame/sepia.html>
<http://my.opera.com/WebApplications/blog/show.dml/200788>
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: frizzle |
last post by:
Hi there,
i have a site for some friends who are abbroad for school.
it has a mysql guestbook and a few other things to communicate.
it also needs a photo-album on it.
now since my friends...
|
by: Rune Johansen |
last post by:
Hi.
I'm doing some image manipulation in an applet using the example code on
this page:
http://www.akop.org/art/pixels3.htm
However, I really want an application rather than an applet, I just...
|
by: Dj Frenzy |
last post by:
Hi, I know how to use javascript to change a background image to
another background image, and how to change a background colour to
another background colour. Is there a way to change an image to a...
|
by: Steve Amey |
last post by:
Hi all
I have an ARGB value for a Colour (Eg. -65536. The value was retrieved by
using the Color.ToArgb method), is there any way that I can create a
System.Drawing.Image or a...
|
by: Job |
last post by:
Hi,
I would like to find out what ASP/ASP.net can do with image manipulation.
Does ASP have built in functions (eg. after upload to server) to
manipulate images, like rotate, scale, crop etc.?...
|
by: Fuzzyman |
last post by:
Hello all,
I'm using a website creation tool (called `rest2web
<http://www.voidspace.org.uk/python/rest2web/>`_) that lets me store my
content in a text based format ( `ReStructuredText...
|
by: zacariaz |
last post by:
I dont know, and i dont much like javascript, however, i am told that
the only way to do want i want to do, is with javascript, so here goes.
zoom and cut is the only features i need.
1. the...
|
by: spgedwards |
last post by:
I am trying to run a basic script that displays an existing jpeg image
and writes some text over it. Sounds simple, but I cannot seem to be
able to colour the font correctly. In the example below...
|
by: Robin Becker |
last post by:
I have an RGBA .png which PIL is able to read and I would like to convert the
image to a simple RGB image with a single colour reserved for transparent as the
A channel is either all on or all off....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
|
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,...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |