DIGIT-ARC read-only archive · snapshot: July 23, 2026

Javascript wanted

18 posts · originally from https://geek.digit.in/community/threads/javascript-wanted.81042/

casanova
casanova Original post #1
Feb 25, 2008 at 7:50 PM
I need a javascript that can determine the most frequently occuring color in an image and set the windows background color to the most frequently occuring color.

Java scripters, any1 here.
victor_rambo
Feb 25, 2008 at 7:54 PM
Not possible using javascript AFAIK!
QwertyManiac
Feb 25, 2008 at 8:29 PM
You want it in Java or JavaScript? :?
Faun
Faun #4
Feb 25, 2008 at 8:37 PM
possible in java using image processing class
search a bit
casanova
Feb 25, 2008 at 8:48 PM
Want it in Javascript. Couldn't find one.

Might be something else that can do that will work as long as I can find a way to call it through a javascript.
QwertyManiac
Feb 25, 2008 at 8:56 PM
JavaScript is client-side scripting, you wont be able to do it even then unless you make the user run some particular thing which returns to your script.

And no, JavaScript has no image processing libraries.

Better use a Java Applet?
casanova
Feb 25, 2008 at 9:13 PM
I would be running that off my comp itself. I would be triggering this from a software that I use which supports calling Javascripts.
Faun
Faun #8
Feb 25, 2008 at 9:19 PM
I would be running that off my comp itself. I would be triggering this from a software that I use which supports calling Javascripts.

may be u could use JSP for that if its a web app.
casanova
Feb 25, 2008 at 9:38 PM
Its not a web app. Sadly, I can't manage to do this on my own as I have never handled images previously and completely out of coding these days.

A brief description on how I would make the script act,
1. An image in a particular folder would be changed regularly
2. Once this image is changed, the javascript would be triggered. Incase there is a tiny application that can do that and exit, it would be fine as well.

Found this algorithm. No idea on how to implement it though
QwertyManiac
Feb 25, 2008 at 11:38 PM
I don't get your idea even now, what language are you writing your software in? Doesnt it have image libraries?

JS can't help with images, forget it. Nor does it allow calling other executables, so using it as a link is not possible as well.
Faun
Faun #11
Feb 25, 2008 at 11:42 PM
I don't get your idea even now, what language are you writing your software in? Doesnt it have image libraries?

JS can't help with images, forget it. Nor does it allow calling other executables, so using it as a link is not possible as well.
yup thats the security measure.

u may consider M$ .Net :D

Can u be less terse, elaborate it concisely.
Krazy_About_Technology
Feb 26, 2008 at 1:30 AM
u may consider M$ .Nert
Yaar, is it always required to use this language with all things MS, whether good or bad :-| . Its quiet annoying.

Anyways, Yup, a .NET app will do i think, whether a Windows Form or Web app. There is not much diff anyways in .NET. Even with aspx pages, code running on server will have full access to whatever resource you want.
casanova
casanova #13
Feb 26, 2008 at 7:06 AM
QwertyManiac said:
I don't get your idea even now, what language are you writing your software in? Doesnt it have image libraries?
I haven't written any softy. But a few of the softwares I use allow calling a javascript.

QwertyManiac said:
JS can't help with images, forget it. Nor does it allow calling other executables, so using it as a link is not possible as well.
Good that I asked first rather than jus googling for the impossible.

Can it possible with a VB script. This does allow calling an exe for sure, can it handle images
Gigacore
Gigacore #14
Feb 26, 2008 at 7:10 AM
I use a JS in one of my sites, which can handle images and picks up the color from it. I think it can't be used in ur case.
casanova
casanova #15
Feb 26, 2008 at 10:23 AM
If it picks up the most frequent color, then I think it might be what I was looking for.
Gigacore
Gigacore #16
Feb 26, 2008 at 11:11 AM
^ it wont. It can just pic one color at a time. Infact its a color palette JS. But maybe you can play with the codes. You can find the js here: *johndyer.name
casanova
casanova #17
Feb 26, 2008 at 11:55 AM
Not what I need.

i just came across this vbscript

I wonder if it can be tailored to fit my needs
casanova
casanova #18
Mar 3, 2008 at 12:52 PM
I have now managed to write an algorithm that would do my job. Can some1 convert this algorithm to vbscript or a javascript

image=read_the_image(d:\casanova.jpg)
colours_found=0
width=get_image_width(image)
height=get_image_height(image)

for (i=0;i<width;i++)
{
for (j=0;j<height;j++)
{
new_colour_found=1 //treat as is this is a new colour
pixel_colour=get_colour_at(i,j)
for (k=0;k<colours_found;k++)
{
if (colour[k][0]=pixel_colour)
{
colour[k][1]=colour[k][1]+1
new_colour_found=0 //this colour is not new
break
}
}
if (new_colour_found=1)
{
colours_found=colours_found+1
colour[colours_found][0]=pixel_colour
colour[colours_found][1]=1
}
}
}


max[0][1]=0
//finding the most frequent colour
for (k=0;k<colours_found;k++)
{
if (colour[k][1]>max[0][1])
{
max[0][0]=colour[k][0]
max[0][1]=colour[k][1]
}
}
set_desktop_background_colour(max[0][0])