Copy link to clipboard
Copied
When i run following script on attached png sample file:
https://drive.google.com/file/d/1aYQTyKwc2xkRtkq9VOe2Fimhw4GlshEm
i get following error:
How to fix this error?
Note that this script was not written by me and written by one of the users of this community. The script runs on that user's system without any problems, but it gives an error on my system and others.
Note that to test the script, it must be executed on the attached PNG sample file.
Copy link to clipboard
Copied
////// get histogram //////
function histogram () {
/////////////////
////// select the composite channel as the active channel. the current one can be a mask.
/////////////////
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("RGB"));
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
/////////////////
/////////////////
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("histogram"));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var docDesc = executeActionGet(ref);
var list = docDesc.getList(stringIDToTypeID("histogram"));
var theArray = new Array;
var theTotal = 0;
for (var i = 0; i < list.count; i++) {
var d = list.getInteger(i);
theArray.push(d);
theTotal = theTotal+d;
};
return [theArray, theTotal];
};
Copy link to clipboard
Copied
modify histogram() function like this:
By @r-bin
tnq very much it worked for me by modify script
Find more inspiration, events, and resources on the new Adobe Community
Explore Now