This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Computer Graphics with Photoshop > September 2006 > Accessing individual pixels of an image with Javascript
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Accessing individual pixels of an image with Javascript
|
|
| Hitchkas 2006-09-03, 6:16 pm |
| How one accesses individual pixels of an image in Javascript for
PhotoShop? For example is there a method that allows something like
the following?
//x, and y pixel coordinates along width and height of image
Image.Channel.Red(x, y) = 128;
Namely, how one can read and write an individual pixel value of an
image?
| |
| Ripley 2006-09-04, 6:21 am |
| found this somewhere:
//////////////////
var pixelColor = getPixelColor(100,100); // the two values are the
horizontal and vertical position of the pixel you want the color from
function getPixelColor(pixH,pixV){ // this only works for an active RGB
document
var selRegion = null;
selRegion = Array(Array(pixH, pixV),
Array(pixH + 1, pixV),
Array(pixH + 1, pixV + 1),
Array(pixH, pixV + 1),
Array(pixH, pixV));
var currDoc = app.activeDocument;
currDoc.selection.select(selRegion);
var histR = currDoc.channels.getByName("Red").histogram;
var histG = currDoc.channels.getByName("Green").histogram;
var histB = currDoc.channels.getByName("Blue").histogram;
var returnColor = new RGBColor();
for (iHistR in histR){
if(histR[iHistR]!=0){
returnColor.red = iHistR;
}
}
for (iHistG in histG){
if(histG[iHistG]!=0){
returnColor.green = iHistG;
}
}
for (iHistB in histB){
if(histB[iHistB]!=0){
returnColor.blue = iHistB;
}
}
return returnColor;
}
alert(pixelColor.hexValue+"\n"+pixelColor.red+","+pixelColor.green+","+pixel
Color.blue);
/////////////////////
and to fill that with new color:
var color = new SolidColor();
color.rgb["hexValue"] = "00ff00";
currDoc.selection.fill(color);
R
"Hitchkas" <hitchkas@XXXXXXXXXX> wrote in message
news:1157321285.771358.303980@m73g2000cwd.googlegroups.com...
> How one accesses individual pixels of an image in Javascript for
> PhotoShop? For example is there a method that allows something like
> the following?
>
> //x, and y pixel coordinates along width and height of image
> Image.Channel.Red(x, y) = 128;
>
> Namely, how one can read and write an individual pixel value of an
> image?
>
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|