Last active
April 24, 2019 06:41
-
-
Save Revnart/e81f6afbae44b9b4bffcaa4e4d6b6afd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Author: revnart@gmail.com | |
// 04/2019 | |
// L RANGE SELECTOR | |
// | |
/* | |
<javascriptresource> | |
<name>[R] Select L range 2.1</name> | |
<enableinfo>true</enableinfo> | |
<category>Revnart</category> | |
</javascriptresource> | |
*/ | |
#target photoshop | |
var doc = app.activeDocument; | |
//USER INTERFACE | |
var myWindow = new Window ("dialog", '"L" Range'); | |
myWindow.orientation = "column"; | |
var inputsMin = myWindow.add ("group"); | |
inputsMin.orientation = "row"; | |
inputsMin.add ("statictext", undefined, "Min. value:"); | |
var minval = inputsMin.add ("edittext", undefined, 0); | |
minval.characters = 10; | |
minval.active = true; | |
var inputsMax = myWindow.add ("group"); | |
inputsMax.orientation = "row"; | |
inputsMax.add ("statictext", undefined, "Max. value:"); | |
var maxval = inputsMax.add ("edittext", undefined, 100); | |
maxval.characters = 10; | |
var myButtonGroup = myWindow.add ("group"); | |
myButtonGroup.orientation = "column"; | |
myButtonGroup.add ("button", undefined, "OK"); | |
myButtonGroup.add ("button", undefined, "Cancel"); | |
myWindow.show (); | |
//ADDITIONAL TWEAK TO SELECT ALL PIXELS WITH DESIRED "L" VALUE | |
var minval = Number(minval.text) - 0.1; | |
var maxval = Number(maxval.text) + 0.1; | |
//COLOR RANGE SELECTION | |
var idClrR = charIDToTypeID( "ClrR" ); | |
var desc4 = new ActionDescriptor(); | |
var idFzns = charIDToTypeID( "Fzns" ); | |
//FUZINESS AMOUNT | |
desc4.putInteger( idFzns, 0 ); | |
var idMnm = charIDToTypeID( "Mnm " ); | |
var desc5 = new ActionDescriptor(); | |
var idLmnc = charIDToTypeID( "Lmnc" ); | |
desc5.putDouble( idLmnc, minval ); | |
var idA = charIDToTypeID( "A " ); | |
//MINIMUM "A" VALUE | |
desc5.putDouble( idA, -128 ); | |
var idB = charIDToTypeID( "B " ); | |
//MINIMUM "B "VALUE | |
desc5.putDouble( idB, -128 ); | |
var idLbCl = charIDToTypeID( "LbCl" ); | |
desc4.putObject( idMnm, idLbCl, desc5 ); | |
var idMxm = charIDToTypeID( "Mxm " ); | |
var desc6 = new ActionDescriptor(); | |
var idLmnc = charIDToTypeID( "Lmnc" ); | |
desc6.putDouble( idLmnc, maxval ); | |
var idA = charIDToTypeID( "A " ); | |
//MAXIMUM "A" VALUE | |
desc6.putDouble( idA, 127 ); | |
var idB = charIDToTypeID( "B " ); | |
//MAXIMUM "B" VALUE | |
desc6.putDouble( idB, 127 ); | |
var idLbCl = charIDToTypeID( "LbCl" ); | |
desc4.putObject( idMxm, idLbCl, desc6 ); | |
var idcolorModel = stringIDToTypeID( "colorModel" ); | |
desc4.putInteger( idcolorModel, 0 ); | |
executeAction( idClrR, desc4, DialogModes.NO ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment