Copy link to clipboard
Copied
I am currently trying to script the color range command, to allow one pass to effect the next. Specically with midtones which have three input values (fuzziness, midtonesLowerLimit and midtonesUpperLimit).
How do i get these values from the command??
I have a sucessfully extracted the color range command from script listener and am able to input values. However i am really struggling to get values from it.
I know i need to use the executeActionGet command, but havent a clue how to implement it,
Here is my script for which allows me to input values, could someone show me how to get values from the last run command.
function colorRange(fuzz, lowLim, highLim){
var idClrR = charIDToTypeID( "ClrR" );
var desc25 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
var idClrs = charIDToTypeID( "Clrs" );
var idMdtn = charIDToTypeID( "Mdtn" );
desc25.putEnumerated( idClrs, idClrs, idMdtn );
var idmidtonesFuzziness = stringIDToTypeID( "midtonesFuzziness" );
desc25.putInteger( idmidtonesFuzziness, fuzz );
var idmidtonesLowerLimit = stringIDToTypeID( "midtonesLowerLimit" );
desc25.putInteger( idmidtonesLowerLimit, lowLim );
var idmidtonesUpperLimit = stringIDToTypeID( "midtonesUpperLimit" );
desc25.putInteger( idmidtonesUpperLimit, highLim );
var idcolorModel = stringIDToTypeID( "colorModel" );
desc25.putInteger( idcolorModel, 1 );
var iddimension = stringIDToTypeID( "dimension" );
desc25.putInteger( iddimension, 5 );
var idposGaussClusters = stringIDToTypeID( "posGaussClusters" );
desc25.putInteger( idposGaussClusters, 7 );
var idposGaussTolerance = stringIDToTypeID( "posGaussTolerance" );
desc25.putDouble( idposGaussTolerance, 0.156860 );
var idposSpaGaussTolerance = stringIDToTypeID( "posSpaGaussTolerance" );
desc25.putDouble( idposSpaGaussTolerance, 1.000000 );
var idposGaussParams = stringIDToTypeID( "posGaussParams" );
var list4 = new ActionList();
list4.putDouble( 0.428589 );
list4.putDouble( 0.497375 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.502930 );
list4.putDouble( 0.506165 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.403625 );
list4.putDouble( 0.424194 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.019958 );
list4.putDouble( 0.194580 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.580566 );
list4.putDouble( 0.620026 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.567047 );
list4.putDouble( 0.717468 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.499817 );
list4.putDouble( 0.505768 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.432800 );
list4.putDouble( 0.439209 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.532990 );
list4.putDouble( 0.976837 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.233734 );
list4.putDouble( 0.343140 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.670044 );
list4.putDouble( 0.721954 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.505585 );
list4.putDouble( 0.508148 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.472900 );
list4.putDouble( 0.483490 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.503265 );
list4.putDouble( 0.517212 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.264252 );
list4.putDouble( 0.287903 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.298706 );
list4.putDouble( 0.419098 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.510773 );
list4.putDouble( 0.513092 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.454529 );
list4.putDouble( 0.460144 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.428070 );
list4.putDouble( 0.448059 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.398102 );
list4.putDouble( 0.478302 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.338715 );
list4.putDouble( 0.344269 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.510834 );
list4.putDouble( 0.511780 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.410767 );
list4.putDouble( 0.413818 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.025757 );
list4.putDouble( 0.049683 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.446991 );
list4.putDouble( 0.480408 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.572021 );
list4.putDouble( 0.673645 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.501099 );
list4.putDouble( 0.513885 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.407074 );
list4.putDouble( 0.516449 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.010254 );
list4.putDouble( 0.384949 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.285797 );
list4.putDouble( 0.643158 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.614441 );
list4.putDouble( 0.631012 );
list4.putDouble( 0.156860 );
list4.putDouble( 0.521301 );
list4.putDouble( 0.521576 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.517761 );
list4.putDouble( 0.525024 );
list4.putDouble( 0.051764 );
list4.putDouble( 0.356018 );
list4.putDouble( 0.367859 );
list4.putDouble( 1.000000 );
list4.putDouble( 0.292389 );
list4.putDouble( 0.302124 );
list4.putDouble( 1.000000 );
desc25.putList( idposGaussParams, list4 );
var idnegGaussClusters = stringIDToTypeID( "negGaussClusters" );
desc25.putInteger( idnegGaussClusters, 0 );
var idnegGaussTolerance = stringIDToTypeID( "negGaussTolerance" );
desc25.putDouble( idnegGaussTolerance, 0.086273 );
var idnegSpaGaussTolerance = stringIDToTypeID( "negSpaGaussTolerance" );
desc25.putDouble( idnegSpaGaussTolerance, 1.000000 );
var idnegGaussParams = stringIDToTypeID( "negGaussParams" );
var list5 = new ActionList();
desc25.putList( idnegGaussParams, list5 );
executeAction( idClrR, desc25, DialogModes.NO );
}
Breakthrough,
got it to work and pass values through!!
var theVal = ColorRange();
getVal (theVal)
fuzz = MidVal[1]
lowLim = MidVal[2]
midLim = MidVal[3]
function getVal (theDesc) {
var c = theDesc.count;
var str = '';
MidVal = new Array;
for(var i=0;i<c;i++){
MidVal.push(+getValues (theDesc, i))
};
}
function ColorRange () {
try {
var desc16 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
va
...
Copy link to clipboard
Copied
Hmmm....
//Fuzziness, Lower Limit, Upperlimit, ?
colorRangeMidtones(50, 25, 75, 0);
function colorRangeMidtones(midtonesFuzziness, midtonesLowerLimit, midtonesUpperLimit, colorModel) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
descriptor.putEnumerated( s2t( "colors" ), s2t( "colors" ), s2t( "midtones" ));
descriptor.putInteger( s2t( "midtonesFuzziness" ), midtonesFuzziness );
descriptor.putInteger( s2t( "midtonesLowerLimit" ), midtonesLowerLimit );
descriptor.putInteger( s2t( "midtonesUpperLimit" ), midtonesUpperLimit );
descriptor.putInteger( s2t( "colorModel" ), colorModel );
executeAction( s2t( "colorRange" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
Hi Stephen,
Lovely work,
However what i am wanting is to be able to get the values not input them, any idea how to do that?
Copy link to clipboard
Copied
Ah sorry, this is above my pay-grade!
Copy link to clipboard
Copied
i dunno your code looks pretty elegant,
I know its something to do with using executeActionGet and changing putInteger to getInteger.... but im def missing something as still throwing errors
Copy link to clipboard
Copied
All I did was use CleanSL to refine the scripting listener code and wrap it into a function:
https://github.com/rendertom/Clean-SL
https://community.adobe.com/t5/photoshop/clean-sl/td-p/9358420
Copy link to clipboard
Copied
that's a great utility thanks for the links
Copy link to clipboard
Copied
I have found some help on this courtesy of the following board How do I find out the value passed to Action in jsx?
function ColorRange () {
try {
var desc16 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
var idClrs = charIDToTypeID( "Clrs" );
var idMdtn = charIDToTypeID( "Mdtn" );
desc16.putEnumerated( idClrs, idClrs, idMdtn );
var theRes = executeAction(charIDToTypeID( "ClrR" ), desc16, DialogModes.ALL );
return theRes
} catch (e) {return false}
};
var theRes = ColorRange();
checkDesc2 (theRes);
////////////////////////////////////
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
alert("desc\n\n"+ str);
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
However i'm still not sure how to extract the values from this script, they are appearing correctly on an alert, but i want to have them seperated to pass on to a following color range command
Copy link to clipboard
Copied
Breakthrough,
got it to work and pass values through!!
var theVal = ColorRange();
getVal (theVal)
fuzz = MidVal[1]
lowLim = MidVal[2]
midLim = MidVal[3]
function getVal (theDesc) {
var c = theDesc.count;
var str = '';
MidVal = new Array;
for(var i=0;i<c;i++){
MidVal.push(+getValues (theDesc, i))
};
}
function ColorRange () {
try {
var desc16 = new ActionDescriptor();
var idClrs = charIDToTypeID( "Clrs" );
var idClrs = charIDToTypeID( "Clrs" );
var idMdtn = charIDToTypeID( "Mdtn" );
desc16.putEnumerated( idClrs, idClrs, idMdtn );
var theDesc = executeAction(charIDToTypeID( "ClrR" ), desc16, DialogModes.ALL );
return theDesc
} catch (e) {return false}
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
I been searching for something like this, as I can return the value/radius of a filter that has one input, but can't really figure out how when the filter has 2 or 3 values. I'm trying to make a script that takes the blur radius, and divide that number by 3 to get its values, then multiply the blur radius by 2. Like I said I can do this using Gaussian Blur or Median as the user just uses one input. Any suggestions?