|
// 2015, use it at your own risk;
#target "photoshop-70.032"
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theName = myDocument.name;
try {var theName = theName.match(/(.*)\.[^\.]+$/)[1]} catch (e) {};
try {var thePath = myDocument.path}
catch (e) {var thePath = "~/Desktop"};
if (myDocument.mode == DocumentMode.MULTICHANNEL || myDocument.mode == DocumentMode.GRAYSCALE) {
var theHistogram = myDocument.channels[0].histogram
};
else {var theHistogram = myDocument.histogram};
// get total number of histogram:
var theNumber = 0;
for (var m = 0; m < theHistogram.length; m++) {theNumber = theNumber + theHistogram};
copyTextToClipboard (theNumber);
/* var theText = new File(thePath+"/"+theName+"_histo.txt");
theText.open("w");
for (a = 0; a < theHistogram.length; a++){
// this line adds the number of the histogram-level;
theText.write(bufferNumberWithZeros(a,3)+"_");
// this line adds the number pixels of the respective histogram-level;
theText.write(theHistogram);
theText.write("\n")
}
theText.close();*/
}
else {
alert ("no open document")
};
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
var theNumberString = String(number);
for (var o = 0; o < (places - String(number).length); o++) {
theNumberString = String("0" + theNumberString)
};
return theNumberString
};
//////
function copyTextToClipboard( txt ) {
const keyTextData = app.charIDToTypeID('TxtD');
const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" );
var textStrDesc = new ActionDescriptor();
textStrDesc.putString( keyTextData, txt );
executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO );
};
|