其他分享
首页 > 其他分享> > Photoshop插件--平滑渐变过渡曲线--通道混合器--增强全部图层--脚本开发--PS插件

Photoshop插件--平滑渐变过渡曲线--通道混合器--增强全部图层--脚本开发--PS插件

作者:互联网

文章目录


  PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本实现平滑渐变过渡曲线、通道混合器和增强全部图层相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。

1.插件界面

  本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
在这里插入图片描述

2.关键代码

2.1 平滑渐变过渡曲线

  大家可通过源代码阅读,来掌握相关技巧,源代码如下:

//
// Generated Fri May 01 2015 07:28:02 GMT+0600
//

//
//==================== Solar Curve ==============
//
function SolarCurve() {
    // Make
    function step1(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSClass.AdjustmentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
        desc2.putObject(PSKey.Type, PSClass.Curves, desc3);
        desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Select
    function step2(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Set
    function step3(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Solar_Curve");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Select
    function step4(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Delete
    function step5(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Set
    function step6(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
        var list1 = new ActionList();
        var desc3 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Red);
        desc3.putReference(PSClass.Channel, ref2);
        var list2 = new ActionList();
        var desc4 = new ActionDescriptor();
        desc4.putDouble(PSKey.Horizontal, 0);
        desc4.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc4);
        var desc5 = new ActionDescriptor();
        desc5.putDouble(PSKey.Horizontal, 41);
        desc5.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc5);
        var desc6 = new ActionDescriptor();
        desc6.putDouble(PSKey.Horizontal, 92);
        desc6.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc6);
        var desc7 = new ActionDescriptor();
        desc7.putDouble(PSKey.Horizontal, 143);
        desc7.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc7);
        var desc8 = new ActionDescriptor();
        desc8.putDouble(PSKey.Horizontal, 194);
        desc8.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc8);
        var desc9 = new ActionDescriptor();
        desc9.putDouble(PSKey.Horizontal, 255);
        desc9.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc9);
        desc3.putList(PSKey.Curve, list2);
        list1.putObject(PSClass.CurvesAdjustment, desc3);
        var desc10 = new ActionDescriptor();
        var ref3 = new ActionReference();
        ref3.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Green);
        desc10.putReference(PSClass.Channel, ref3);
        var list3 = new ActionList();
        var desc11 = new ActionDescriptor();
        desc11.putDouble(PSKey.Horizontal, 0);
        desc11.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc11);
        var desc12 = new ActionDescriptor();
        desc12.putDouble(PSKey.Horizontal, 51);
        desc12.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc12);
        var desc13 = new ActionDescriptor();
        desc13.putDouble(PSKey.Horizontal, 102);
        desc13.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc13);
        var desc14 = new ActionDescriptor();
        desc14.putDouble(PSKey.Horizontal, 153);
        desc14.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc14);
        var desc15 = new ActionDescriptor();
        desc15.putDouble(PSKey.Horizontal, 204);
        desc15.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc15);
        var desc16 = new ActionDescriptor();
        desc16.putDouble(PSKey.Horizontal, 255);
        desc16.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc16);
        desc10.putList(PSKey.Curve, list3);
        list1.putObject(PSClass.CurvesAdjustment, desc10);
        var desc17 = new ActionDescriptor();
        var ref4 = new ActionReference();
        ref4.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Blue);
        desc17.putReference(PSClass.Channel, ref4);
        var list4 = new ActionList();
        var desc18 = new ActionDescriptor();
        desc18.putDouble(PSKey.Horizontal, 0);
        desc18.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc18);
        var desc19 = new ActionDescriptor();
        desc19.putDouble(PSKey.Horizontal, 61);
        desc19.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc19);
        var desc20 = new ActionDescriptor();
        desc20.putDouble(PSKey.Horizontal, 112);
        desc20.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc20);
        var desc21 = new ActionDescriptor();
        desc21.putDouble(PSKey.Horizontal, 163);
        desc21.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc21);
        var desc22 = new ActionDescriptor();
        desc22.putDouble(PSKey.Horizontal, 214);
        desc22.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc22);
        var desc23 = new ActionDescriptor();
        desc23.putDouble(PSKey.Horizontal, 255);
        desc23.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc23);
        desc17.putList(PSKey.Curve, list4);
        list1.putObject(PSClass.CurvesAdjustment, desc17);
        desc2.putList(PSKey.Adjustment, list1);
        desc1.putObject(PSKey.To, PSClass.Curves, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step7(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    step1();      // Make
    step2();      // Select
    step3();      // Set
    step4();      // Select
    step5();      // Delete
    step6();      // Set
    step7();      // Set
};


cTID = function (s) {
    return app.charIDToTypeID(s);
};
sTID = function (s) {
    return app.stringIDToTypeID(s);
};

//
// SolarCurve.loadSymbols
//   Loading up the symbol definitions like this makes it possible
//   to include several of these generated files in one master file
//   provided a prefix is specified other than the default. It also
//   skips the definitions if PSConstants has already been loaded.
//
SolarCurve.loadSymbols = function () {
    var dbgLevel = $.level;
    $.level = 0;
    try {
        PSConstants;
        return; // only if PSConstants is defined
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    var needDefs = true;
    $.level = 0;
    try {
        PSClass;
        needDefs = false;
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    if (needDefs) {
        PSClass = function () {
        };
        PSEnum = function () {
        };
        PSEvent = function () {
        };
        PSForm = function () {
        };
        PSKey = function () {
        };
        PSType = function () {
        };
        PSUnit = function () {
        };
        PSString = function () {
        };
    }

    // We may still end up duplicating some of the following definitions
    // but at least we don't redefine PSClass, etc... and wipe out others
    PSClass.AdjustmentLayer = cTID('AdjL');
    PSClass.Calculation = cTID('Clcl');
    PSClass.Channel = cTID('Chnl');
    PSClass.Curves = cTID('Crvs');
    PSClass.CurvesAdjustment = cTID('CrvA');
    PSClass.Layer = cTID('Lyr ');
    PSClass.Mask = cTID('Msk ');
    PSClass.Point = cTID('Pnt ');
    PSClass.RGBColor = cTID('RGBC');
    PSEnum.Blue = cTID('Bl  ');
    PSEnum.Composite = cTID('Cmps');
    PSEnum.Green = cTID('Grn ');
    PSEnum.HideAll = cTID('HdAl');
    PSEnum.Luminosity = cTID('Lmns');
    PSEnum.Merged = cTID('Mrgd');
    PSEnum.Overlay = cTID('Ovrl');
    PSEnum.RGB = cTID('RGB ');
    PSEnum.Red = cTID('Rd  ');
    PSEnum.Target = cTID('Trgt');
    PSEvent.Delete = cTID('Dlt ');
    PSEvent.Desaturate = cTID('Dstt');
    PSEvent.Make = cTID('Mk  ');
    PSEvent.Select = cTID('slct');
    PSEvent.Set = cTID('setd');
    PSKey.Adjustment = cTID('Adjs');
    PSKey.At = cTID('At  ');
    PSKey.Color = cTID('Clr ');
    PSKey.Curve = cTID('Crv ');
    PSKey.Exposure = cTID('Exps');
    PSKey.From = cTID('From');
    PSKey.Horizontal = cTID('Hrzn');
    PSKey.MakeVisible = cTID('MkVs');
    PSKey.Mode = cTID('Md  ');
    PSKey.Name = cTID('Nm  ');
    PSKey.New = cTID('Nw  ');
    PSKey.Offset = cTID('Ofst');
    PSKey.Opacity = cTID('Opct');
    PSKey.Radius = cTID('Rds ');
    PSKey.To = cTID('T   ');
    PSKey.Type = cTID('Type');
    PSKey.Using = cTID('Usng');
    PSKey.Vertical = cTID('Vrtc');
    PSKey.With = cTID('With');
    PSString.Null = sTID('null');
    PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
    PSString.contentLayer = sTID('contentLayer');
    PSString.gammaCorrection = sTID('gammaCorrection');
    PSString.layerGroup = sTID('layerSection');
    PSString.presetKind = sTID('presetKind');
    PSString.presetKindCustom = sTID('presetKindCustom');
    PSString.presetKindDefault = sTID('presetKindDefault');
    PSString.presetKindType = sTID('presetKindType');
    PSString.selectionModifier = sTID('selectionModifier');
    PSString.selectionModifierType = sTID('selectionModifierType');
    PSString.solidColorLayer = sTID('solidColorLayer');
    PSType.BlendMode = cTID('BlnM');
    PSType.Ordinal = cTID('Ordn');
    PSType.UserMaskOptions = cTID('UsrM');
    PSUnit.Percent = cTID('#Prc');
    PSUnit.Pixels = cTID('#Pxl');
};

SolarCurve.loadSymbols(); // load up our symbols


//=========================================
//                    SolarCurve.main
//=========================================
//

SolarCurve.main = function () {
    SolarCurve();
};

SolarCurve.main();

// EOF

2.2 通道混合器

  大家可通过源代码阅读,来掌握相关技巧,源代码如下:

//
// Generated Fri May 01 2015 20:42:44 GMT+0600
//

//
//==================== Channel Mixer ==============
//
function ChannelMixer() {
    // Make
    function step1(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSClass.AdjustmentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
        var desc4 = new ActionDescriptor();
        desc4.putUnitDouble(PSEnum.Red, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Red, PSClass.ChannelMatrix, desc4);
        var desc5 = new ActionDescriptor();
        desc5.putUnitDouble(PSEnum.Green, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Green, PSClass.ChannelMatrix, desc5);
        var desc6 = new ActionDescriptor();
        desc6.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Blue, PSClass.ChannelMatrix, desc6);
        desc2.putObject(PSKey.Type, PSClass.ChannelMixer, desc3);
        desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Delete
    function step2(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Set
    function step3(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
        desc2.putBoolean(PSKey.Monochromatic, true);
        var desc3 = new ActionDescriptor();
        desc3.putUnitDouble(PSEnum.Red, PSUnit.Percent, -75);
        desc3.putUnitDouble(PSEnum.Green, PSUnit.Percent, 0);
        desc3.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 200);
        desc3.putUnitDouble(PSKey.Constrain, PSUnit.Percent, 0);
        desc2.putObject(PSKey.Gray, PSClass.ChannelMatrix, desc3);
        desc1.putObject(PSKey.To, PSClass.ChannelMixer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step4(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step5(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Channel_Mixer_Help");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step6(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    step1();      // Make
    step2();      // Delete
    step3();      // Set
    step4();      // Set
    step5();      // Set
    step6();      // Set
};


cTID = function (s) {
    return app.charIDToTypeID(s);
};
sTID = function (s) {
    return app.stringIDToTypeID(s);
};

//
// ChannelMixer.loadSymbols
//   Loading up the symbol definitions like this makes it possible
//   to include several of these generated files in one master file
//   provided a prefix is specified other than the default. It also
//   skips the definitions if PSConstants has already been loaded.
//
ChannelMixer.loadSymbols = function () {
    var dbgLevel = $.level;
    $.level = 0;
    try {
        PSConstants;
        return; // only if PSConstants is defined
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    var needDefs = true;
    $.level = 0;
    try {
        PSClass;
        needDefs = false;
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    if (needDefs) {
        PSClass = function () {
        };
        PSEnum = function () {
        };
        PSEvent = function () {
        };
        PSForm = function () {
        };
        PSKey = function () {
        };
        PSType = function () {
        };
        PSUnit = function () {
        };
        PSString = function () {
        };
    }

    // We may still end up duplicating some of the following definitions
    // but at least we don't redefine PSClass, etc... and wipe out others
    PSClass.AdjustmentLayer = cTID('AdjL');
    PSClass.Channel = cTID('Chnl');
    PSClass.ChannelMatrix = cTID('ChMx');
    PSClass.ChannelMixer = cTID('ChnM');
    PSClass.Curves = cTID('Crvs');
    PSClass.CurvesAdjustment = cTID('CrvA');
    PSClass.Layer = cTID('Lyr ');
    PSClass.Mask = cTID('Msk ');
    PSClass.Point = cTID('Pnt ');
    PSClass.RGBColor = cTID('RGBC');
    PSEnum.Blue = cTID('Bl  ');
    PSEnum.Green = cTID('Grn ');
    PSEnum.RGB = cTID('RGB ');
    PSEnum.Red = cTID('Rd  ');
    PSEnum.Target = cTID('Trgt');
    PSEvent.Delete = cTID('Dlt ');
    PSEvent.Hide = cTID('Hd  ');
    PSEvent.Make = cTID('Mk  ');
    PSEvent.Select = cTID('slct');
    PSEvent.Set = cTID('setd');
    PSKey.Adjustment = cTID('Adjs');
    PSKey.Color = cTID('Clr ');
    PSKey.Constrain = cTID('Cnst');
    PSKey.Curve = cTID('Crv ');
    PSKey.Exposure = cTID('Exps');
    PSKey.From = cTID('From');
    PSKey.Gray = cTID('Gry ');
    PSKey.Horizontal = cTID('Hrzn');
    PSKey.MakeVisible = cTID('MkVs');
    PSKey.Mode = cTID('Md  ');
    PSKey.Monochromatic = cTID('Mnch');
    PSKey.Name = cTID('Nm  ');
    PSKey.Offset = cTID('Ofst');
    PSKey.To = cTID('T   ');
    PSKey.Type = cTID('Type');
    PSKey.Using = cTID('Usng');
    PSKey.Vertical = cTID('Vrtc');
    PSString.Null = sTID('null');
    PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
    PSString.contentLayer = sTID('contentLayer');
    PSString.gammaCorrection = sTID('gammaCorrection');
    PSString.layerGroup = sTID('layerSection');
    PSString.presetKind = sTID('presetKind');
    PSString.presetKindCustom = sTID('presetKindCustom');
    PSString.presetKindDefault = sTID('presetKindDefault');
    PSString.presetKindType = sTID('presetKindType');
    PSString.selectionModifier = sTID('selectionModifier');
    PSString.selectionModifierType = sTID('selectionModifierType');
    PSString.solidColorLayer = sTID('solidColorLayer');
    PSType.BlendMode = cTID('BlnM');
    PSType.Ordinal = cTID('Ordn');
    PSUnit.Percent = cTID('#Prc');
};

ChannelMixer.loadSymbols(); // load up our symbols


//=========================================
//                    ChannelMixer.main
//=========================================
//

ChannelMixer.main = function () {
    ChannelMixer();
};

ChannelMixer.main();

// EOF

2.3 增强全部图层

  大家可通过源代码阅读,来掌握相关技巧,源代码如下:

//
// Generated Fri May 01 2015 20:42:44 GMT+0600
//

//
//==================== All Help ==============
//
function AllHelp() {
    // Make
    function step1(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSClass.AdjustmentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
        desc2.putObject(PSKey.Type, PSClass.Curves, desc3);
        desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Select
    function step2(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Set
    function step3(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Solar_Curve");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Select
    function step4(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Delete
    function step5(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Set
    function step6(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
        var list1 = new ActionList();
        var desc3 = new ActionDescriptor();
        var ref2 = new ActionReference();
        ref2.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Red);
        desc3.putReference(PSClass.Channel, ref2);
        var list2 = new ActionList();
        var desc4 = new ActionDescriptor();
        desc4.putDouble(PSKey.Horizontal, 0);
        desc4.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc4);
        var desc5 = new ActionDescriptor();
        desc5.putDouble(PSKey.Horizontal, 41);
        desc5.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc5);
        var desc6 = new ActionDescriptor();
        desc6.putDouble(PSKey.Horizontal, 92);
        desc6.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc6);
        var desc7 = new ActionDescriptor();
        desc7.putDouble(PSKey.Horizontal, 143);
        desc7.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc7);
        var desc8 = new ActionDescriptor();
        desc8.putDouble(PSKey.Horizontal, 194);
        desc8.putDouble(PSKey.Vertical, 0);
        list2.putObject(PSClass.Point, desc8);
        var desc9 = new ActionDescriptor();
        desc9.putDouble(PSKey.Horizontal, 255);
        desc9.putDouble(PSKey.Vertical, 255);
        list2.putObject(PSClass.Point, desc9);
        desc3.putList(PSKey.Curve, list2);
        list1.putObject(PSClass.CurvesAdjustment, desc3);
        var desc10 = new ActionDescriptor();
        var ref3 = new ActionReference();
        ref3.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Green);
        desc10.putReference(PSClass.Channel, ref3);
        var list3 = new ActionList();
        var desc11 = new ActionDescriptor();
        desc11.putDouble(PSKey.Horizontal, 0);
        desc11.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc11);
        var desc12 = new ActionDescriptor();
        desc12.putDouble(PSKey.Horizontal, 51);
        desc12.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc12);
        var desc13 = new ActionDescriptor();
        desc13.putDouble(PSKey.Horizontal, 102);
        desc13.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc13);
        var desc14 = new ActionDescriptor();
        desc14.putDouble(PSKey.Horizontal, 153);
        desc14.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc14);
        var desc15 = new ActionDescriptor();
        desc15.putDouble(PSKey.Horizontal, 204);
        desc15.putDouble(PSKey.Vertical, 0);
        list3.putObject(PSClass.Point, desc15);
        var desc16 = new ActionDescriptor();
        desc16.putDouble(PSKey.Horizontal, 255);
        desc16.putDouble(PSKey.Vertical, 255);
        list3.putObject(PSClass.Point, desc16);
        desc10.putList(PSKey.Curve, list3);
        list1.putObject(PSClass.CurvesAdjustment, desc10);
        var desc17 = new ActionDescriptor();
        var ref4 = new ActionReference();
        ref4.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Blue);
        desc17.putReference(PSClass.Channel, ref4);
        var list4 = new ActionList();
        var desc18 = new ActionDescriptor();
        desc18.putDouble(PSKey.Horizontal, 0);
        desc18.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc18);
        var desc19 = new ActionDescriptor();
        desc19.putDouble(PSKey.Horizontal, 61);
        desc19.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc19);
        var desc20 = new ActionDescriptor();
        desc20.putDouble(PSKey.Horizontal, 112);
        desc20.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc20);
        var desc21 = new ActionDescriptor();
        desc21.putDouble(PSKey.Horizontal, 163);
        desc21.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc21);
        var desc22 = new ActionDescriptor();
        desc22.putDouble(PSKey.Horizontal, 214);
        desc22.putDouble(PSKey.Vertical, 0);
        list4.putObject(PSClass.Point, desc22);
        var desc23 = new ActionDescriptor();
        desc23.putDouble(PSKey.Horizontal, 255);
        desc23.putDouble(PSKey.Vertical, 255);
        list4.putObject(PSClass.Point, desc23);
        desc17.putList(PSKey.Curve, list4);
        list1.putObject(PSClass.CurvesAdjustment, desc17);
        desc2.putList(PSKey.Adjustment, list1);
        desc1.putObject(PSKey.To, PSClass.Curves, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step7(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Make
    function step8(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSString.contentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        var desc4 = new ActionDescriptor();
        desc4.putDouble(PSEnum.Red, 127.998046875);
        desc4.putDouble(PSEnum.Green, 127.998046875);
        desc4.putDouble(PSEnum.Blue, 127.998046875);
        desc3.putObject(PSKey.Color, PSClass.RGBColor, desc4);
        desc2.putObject(PSKey.Type, PSString.solidColorLayer, desc3);
        desc1.putObject(PSKey.Using, PSString.contentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Set
    function step9(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step10(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Black & White");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step11(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSKey.Color);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Select
    function step12(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Delete
    function step13(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Make
    function step14(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSClass.AdjustmentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
        desc3.putDouble(PSKey.Exposure, 0);
        desc3.putDouble(PSKey.Offset, 0);
        desc3.putDouble(PSString.gammaCorrection, 1);
        desc2.putObject(PSKey.Type, PSKey.Exposure, desc3);
        desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Set
    function step15(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Select
    function step16(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSClass.Mask);
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Delete
    function step17(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Set
    function step18(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Detail_Extractor");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Make
    function step19(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSClass.AdjustmentLayer);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        var desc3 = new ActionDescriptor();
        desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault);
        var desc4 = new ActionDescriptor();
        desc4.putUnitDouble(PSEnum.Red, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Red, PSClass.ChannelMatrix, desc4);
        var desc5 = new ActionDescriptor();
        desc5.putUnitDouble(PSEnum.Green, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Green, PSClass.ChannelMatrix, desc5);
        var desc6 = new ActionDescriptor();
        desc6.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 100);
        desc3.putObject(PSEnum.Blue, PSClass.ChannelMatrix, desc6);
        desc2.putObject(PSKey.Type, PSClass.ChannelMixer, desc3);
        desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Delete
    function step20(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        executeAction(PSEvent.Delete, desc1, dialogMode);
    };

    // Set
    function step21(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
        desc2.putBoolean(PSKey.Monochromatic, true);
        var desc3 = new ActionDescriptor();
        desc3.putUnitDouble(PSEnum.Red, PSUnit.Percent, -75);
        desc3.putUnitDouble(PSEnum.Green, PSUnit.Percent, 0);
        desc3.putUnitDouble(PSEnum.Blue, PSUnit.Percent, 200);
        desc3.putUnitDouble(PSKey.Constrain, PSUnit.Percent, 0);
        desc2.putObject(PSKey.Gray, PSClass.ChannelMatrix, desc3);
        desc1.putObject(PSKey.To, PSClass.ChannelMixer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step22(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step23(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "Channel_Mixer_Help");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step24(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Hide
    function step25(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var list1 = new ActionList();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        list1.putReference(ref1);
        desc1.putList(PSString.Null, list1);
        executeAction(PSEvent.Hide, desc1, dialogMode);
    };

    // Select
    function step26(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putName(PSClass.Layer, "Solar_Curve");
        desc1.putReference(PSString.Null, ref1);
        desc1.putEnumerated(PSString.selectionModifier, PSString.selectionModifierType, PSString.addToSelectionContinuous);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Make
    function step27(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putClass(PSString.layerGroup);
        desc1.putReference(PSString.Null, ref1);
        var ref2 = new ActionReference();
        ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSKey.From, ref2);
        executeAction(PSEvent.Make, desc1, dialogMode);
    };

    // Set
    function step28(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSKey.Color, PSKey.Color, PSEnum.Blue);
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Set
    function step29(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putString(PSKey.Name, "All_Help");
        desc1.putObject(PSKey.To, PSClass.Layer, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    // Select
    function step30(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putName(PSClass.Layer, "Detail_Extractor");
        desc1.putReference(PSString.Null, ref1);
        desc1.putBoolean(PSKey.MakeVisible, false);
        executeAction(PSEvent.Select, desc1, dialogMode);
    };

    // Set
    function step31(enabled, withDialog) {
        if (enabled != undefined && !enabled)
            return;
        var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
        var desc1 = new ActionDescriptor();
        var ref1 = new ActionReference();
        ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
        desc1.putReference(PSString.Null, ref1);
        var desc2 = new ActionDescriptor();
        desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom);
        desc2.putDouble(PSString.gammaCorrection, 0.58999997377396);
        desc1.putObject(PSKey.To, PSKey.Exposure, desc2);
        executeAction(PSEvent.Set, desc1, dialogMode);
    };

    step1();      // Make
    step2();      // Select
    step3();      // Set
    step4();      // Select
    step5();      // Delete
    step6();      // Set
    step7();      // Set
    step8();      // Make
    step9();      // Set
    step10();      // Set
    step11();      // Set
    step12();      // Select
    step13();      // Delete
    step14();      // Make
    step15();      // Set
    step16();      // Select
    step17();      // Delete
    step18();      // Set
    step19();      // Make
    step20();      // Delete
    step21();      // Set
    step22();      // Set
    step23();      // Set
    step24();      // Set
    step25();      // Hide
    step26();      // Select
    step27();      // Make
    step28();      // Set
    step29();      // Set
    step30();      // Select
    step31(true, true);      // Set
};


cTID = function (s) {
    return app.charIDToTypeID(s);
};
sTID = function (s) {
    return app.stringIDToTypeID(s);
};

//
// AllHelp.loadSymbols
//   Loading up the symbol definitions like this makes it possible
//   to include several of these generated files in one master file
//   provided a prefix is specified other than the default. It also
//   skips the definitions if PSConstants has already been loaded.
//
AllHelp.loadSymbols = function () {
    var dbgLevel = $.level;
    $.level = 0;
    try {
        PSConstants;
        return; // only if PSConstants is defined
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    var needDefs = true;
    $.level = 0;
    try {
        PSClass;
        needDefs = false;
    } catch (e) {
    } finally {
        $.level = dbgLevel;
    }
    if (needDefs) {
        PSClass = function () {
        };
        PSEnum = function () {
        };
        PSEvent = function () {
        };
        PSForm = function () {
        };
        PSKey = function () {
        };
        PSType = function () {
        };
        PSUnit = function () {
        };
        PSString = function () {
        };
    }

    // We may still end up duplicating some of the following definitions
    // but at least we don't redefine PSClass, etc... and wipe out others
    PSClass.AdjustmentLayer = cTID('AdjL');
    PSClass.Channel = cTID('Chnl');
    PSClass.ChannelMatrix = cTID('ChMx');
    PSClass.ChannelMixer = cTID('ChnM');
    PSClass.Curves = cTID('Crvs');
    PSClass.CurvesAdjustment = cTID('CrvA');
    PSClass.Layer = cTID('Lyr ');
    PSClass.Mask = cTID('Msk ');
    PSClass.Point = cTID('Pnt ');
    PSClass.RGBColor = cTID('RGBC');
    PSEnum.Blue = cTID('Bl  ');
    PSEnum.Green = cTID('Grn ');
    PSEnum.RGB = cTID('RGB ');
    PSEnum.Red = cTID('Rd  ');
    PSEnum.Target = cTID('Trgt');
    PSEvent.Delete = cTID('Dlt ');
    PSEvent.Hide = cTID('Hd  ');
    PSEvent.Make = cTID('Mk  ');
    PSEvent.Select = cTID('slct');
    PSEvent.Set = cTID('setd');
    PSKey.Adjustment = cTID('Adjs');
    PSKey.Color = cTID('Clr ');
    PSKey.Constrain = cTID('Cnst');
    PSKey.Curve = cTID('Crv ');
    PSKey.Exposure = cTID('Exps');
    PSKey.From = cTID('From');
    PSKey.Gray = cTID('Gry ');
    PSKey.Horizontal = cTID('Hrzn');
    PSKey.MakeVisible = cTID('MkVs');
    PSKey.Mode = cTID('Md  ');
    PSKey.Monochromatic = cTID('Mnch');
    PSKey.Name = cTID('Nm  ');
    PSKey.Offset = cTID('Ofst');
    PSKey.To = cTID('T   ');
    PSKey.Type = cTID('Type');
    PSKey.Using = cTID('Usng');
    PSKey.Vertical = cTID('Vrtc');
    PSString.Null = sTID('null');
    PSString.addToSelectionContinuous = sTID('addToSelectionContinuous');
    PSString.contentLayer = sTID('contentLayer');
    PSString.gammaCorrection = sTID('gammaCorrection');
    PSString.layerGroup = sTID('layerSection');
    PSString.presetKind = sTID('presetKind');
    PSString.presetKindCustom = sTID('presetKindCustom');
    PSString.presetKindDefault = sTID('presetKindDefault');
    PSString.presetKindType = sTID('presetKindType');
    PSString.selectionModifier = sTID('selectionModifier');
    PSString.selectionModifierType = sTID('selectionModifierType');
    PSString.solidColorLayer = sTID('solidColorLayer');
    PSType.BlendMode = cTID('BlnM');
    PSType.Ordinal = cTID('Ordn');
    PSUnit.Percent = cTID('#Prc');
};

AllHelp.loadSymbols(); // load up our symbols


//=========================================
//                    AllHelp.main
//=========================================
//

AllHelp.main = function () {
    AllHelp();
};

AllHelp.main();

// EOF

3.作者寄语

  合理的脚本代码可以有效的提高工作效率,减少重复劳动。


  欢迎光临知了软件开发网络平台,本公司定制开发各类软件,主要方向为桌面专业软件开发、插件定制开发、微信小程序(各类小程序)、网站定制开发和App开发,桌面软件主要包括文字图形识别类软件,信息管理类软件,3D打印类软件,视频类软件以及其它涉及专业的各类图形图像处理软件。插件包含AE插件,AI插件,PS插件,PDF插件,3DMAX插件以及Word,Excel等Office插件开发。详情请咨询,微信QQ:312117271,手机:18928899728,邮箱: anjingzhi_sea@163.com.
公司网址:http://www.zhiliaos.com

标签:插件,desc1,--,混合器,ref1,PSKey,PSClass,var,new
来源: https://blog.csdn.net/weixin_42247427/article/details/121954873