Copy link to clipboard
Copied
Is there a way to import/export rgb values for all pixels into a multi-dimensional array with JSX?
Copy link to clipboard
Copied
Only way I know of, just using javascript is to use the eyedropper tool, which would be beyond slow for this purpose. I've done it with sampling various areas, at the most every 50px, and that can still take up to a half hour for a full 4000X3000 image.
Copy link to clipboard
Copied
It's a bit of a hack, but you could probably save it as Photoshop Raw and then read the values directly from the file as binary stream.
Copy link to clipboard
Copied
Paul Riggott once posted something along those lines …
Easy way to extract all pixel Lab values - plea... | Adobe Community
Copy link to clipboard
Copied
Nice, Christoph! I'm going to have to play with that script also, as I do some stuff along those lines.
Copy link to clipboard
Copied
It is a pity that Paul stopped contributing here …
Copy link to clipboard
Copied
That is very interesting. I'll need to give the raw file thing a try.
Also, I wonder if a script file together with a simple filter/plugin file that imports and exports the RGB data could be created? Is it possible for a script to get data from a filter plugin file? Ultimately, what I want is to be able to get the RGB data into an array (and preferable the HSB data too if possible), have the script (or plugin file) create a new array with modified values and then update a layer into photoshop with the new values. I still need the main program to use the JSX scripting because it needs to do a lot of script related tasks. I only have one particular layer that I want to manually calculate new values for each pixel and export directly back into photoshop somehow. I've never create a plugin filter before but I'm thinking that just importing and exporting RGB data would be the first step to learn when creating a plugin filter. Maybe a plugin file that does just that task wouldn't be too hard to create????
Copy link to clipboard
Copied
It would be way more effective to perform all calculations in plugin. It's not that complicated, check Dissolve sample from SDK.
Copy link to clipboard
Copied
I think I agree with that. I'm just struggling on how to get started. Is there any good lessons online for Photoshop plugin creation?
I can't seem to find much documentation at all on plugin creation. I'm not a C++ expert by any means. However, I think I could easily write some simple code to get values from an array, run them through an algorithm and then create a new array of RGB data. I just need to figure out how to get the RGB values from photoshop into the plugin and then how to export the new values from the plugin back into photoshop.
Also, I don't need a UI for the plugin. The JSX script will be the UI. The JSX UI managers about 20 layers. There is just one particular layer that I want for the plugin to be able to manipulate. The script would need to run the plugin and send a few variables to it. The plugin would then update the single layer in Photoshop.
Also, I did look through the Dissolve sample you mentioned. However, that is actual rather complicated for me to figure out. I think what I want to do is actually much less complicated..............if I can just figure out how to get started.
Copy link to clipboard
Copied
Dissolve is pretty simple
check out Dissolve.cpp in common, function DoFilter() does pixel processing in the for loop at the end of function - start changing it.
SDK documentation describes how filter plugin works, btw
Copy link to clipboard
Copied
OK, thanks. I just found the docs you are referring to and they answer a lot of questions I have. Also, the Adobe SDK says that Microsoft Visual Studio Professional is required. Can a different (free) C++ compiler be used instead or is there a reason that Visual Studio must be used to compile?
Copy link to clipboard
Copied
There was free Visual Studio Express before (I suppose it's still there), and I used it to compile plugins succesfully
Copy link to clipboard
Copied
Thanks, I'll give that a try,
Copy link to clipboard
Copied
There is yet another way and that is to use a bitmap in Bridge.
Here is an example it requires a file selected in Bridge, then run the script from ExtendScript Toolkit.
//To be run from ExtendScript Toolkit
#target bridge
getImage();
function getImage() {
var image, bit, data;
image = app.document.selections[0];
bit = new BitmapData( image.spec );
//resize
bit = bit.resize( 100, 'bicubicSharper' );
//get pixel data
data = readColorData( bit );
//example of geing the hex value at x,y
alert(data.x40y34);
//save object to file for later use.
var f = new File(Folder.desktop +"/objData.dat");
f.open('w');
f.write(data.toSource());
f.close();
//empty data object
data={};
//example of loading and using the object
f.open('r');
var newOBJ = eval(f.read());
f.close();
alert("X = 20 Y = 23 Hex Value = " + newOBJ.x20y23);
alert("X = 19 Y = 33 Hex Value = " + newOBJ.x19y33);
};
function readColorData( bitMap ) {
var pix, row, x, y;
//create and populate dynamic object to hold pixel data
mainObj = {};
for ( y = 0; y < bitMap.height; y++ ) {
for ( x = 0; x < bitMap.width; x++ ) {
mainObj ["x"+x+"y"+y] = new Color(bitMap.getPixel(x,y)).toString().match(/[A-Fa-f0-9]{6}$/);
};
};
return mainObj;
};
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more