其他分享
首页 > 其他分享> > Photoshop插件--液化--柔光--叠加--脚本开发--PS插件

Photoshop插件--液化--柔光--叠加--脚本开发--PS插件

作者:互联网

文章目录


  PS是一款栅格图像编辑软件,具有许多强大的功能,本文演示如何通过脚本实现液化、柔光和叠加相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。

1.插件界面

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

2.关键代码

2.1 液化

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

if (app) {
    try {
        Select();
    } catch (e) {

    }
}

function Select() {
    function liquify() {
        var idLqFy = charIDToTypeID("LqFy");
        var desc11 = new ActionDescriptor();
        var idLqMe = charIDToTypeID("LqMe");
        desc11.putData(idLqMe, String.fromCharCode(0, 0, 0, 3, 121, 102, 113, 76, 104, 115, 101, 77, 2, 0, 0, 0, 68, 0, 0, 0, 189, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0));
        executeAction(idLqFy, desc11, DialogModes.ALL);
    }
    liquify.main = function() {
        liquify();
    };
    liquify.main();
}

2.2 柔光

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

if (ScriptUI.environment.keyboardState.shiftKey) {
    var idMk = charIDToTypeID("Mk  ");
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref14 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    ref14.putClass(idLyr);
    desc17.putReference(idnull, ref14);
    executeAction(idMk, desc17, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref15 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref15.putEnumerated(idLyr, idOrdn, idTrgt);
    desc18.putReference(idnull, ref15);
    var idT = charIDToTypeID("T   ");
    var desc19 = new ActionDescriptor();
    var idClr = charIDToTypeID("Clr ");
    var idClr = charIDToTypeID("Clr ");
    var idBl = charIDToTypeID("Bl  ");
    desc19.putEnumerated(idClr, idClr, idBl);
    var idLyr = charIDToTypeID("Lyr ");
    desc18.putObject(idT, idLyr, desc19);
    executeAction(idsetd, desc18, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref16 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref16.putEnumerated(idLyr, idOrdn, idTrgt);
    desc20.putReference(idnull, ref16);
    var idT = charIDToTypeID("T   ");
    var desc21 = new ActionDescriptor();
    var idNm = charIDToTypeID("Nm  ");
    desc21.putString(idNm, "Blank_Overlay");
    var idLyr = charIDToTypeID("Lyr ");
    desc20.putObject(idT, idLyr, desc21);
    executeAction(idsetd, desc20, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref17 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref17.putEnumerated(idLyr, idOrdn, idTrgt);
    desc22.putReference(idnull, ref17);
    var idT = charIDToTypeID("T   ");
    var desc23 = new ActionDescriptor();
    var idMd = charIDToTypeID("Md  ");
    var idBlnM = charIDToTypeID("BlnM");
    var idOvrl = charIDToTypeID("Ovrl");
    desc23.putEnumerated(idMd, idBlnM, idOvrl);
    var idLyr = charIDToTypeID("Lyr ");
    desc22.putObject(idT, idLyr, desc23);
    executeAction(idsetd, desc22, DialogModes.NO);
} else {
    function Overlay() {
        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.Layer);
            desc1.putReference(PSString.Null, ref1);
            var desc2 = new ActionDescriptor();
            desc2.putString(PSKey.Name, "D&B_Overlay");
            desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Overlay);
            desc2.putBoolean(PSKey.FillNeutral, true);
            desc1.putObject(PSKey.Using, PSClass.Layer, desc2);
            executeAction(PSEvent.Make, desc1, dialogMode);
        }

        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.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();
        step2();
    }
    cTID = function(s) {
        return app.charIDToTypeID(s);
    };
    sTID = function(s) {
        return app.stringIDToTypeID(s);
    };
    Overlay.loadSymbols = function() {
        var dbgLevel = $.level;
        $.level = 0;
        try {
            PSConstants;
            return;
        } 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() {

            };
        }
        PSClass.Layer = cTID("Lyr ");
        PSEnum.Blue = cTID("Bl  ");
        PSEnum.Overlay = cTID("Ovrl");
        PSEnum.SoftLight = cTID("SftL");
        PSEnum.Target = cTID("Trgt");
        PSEvent.Make = cTID("Mk  ");
        PSEvent.Set = cTID("setd");
        PSKey.Color = cTID("Clr ");
        PSKey.FillNeutral = cTID("FlNt");
        PSKey.Mode = cTID("Md  ");
        PSKey.Name = cTID("Nm  ");
        PSKey.To = cTID("T   ");
        PSKey.Using = cTID("Usng");
        PSString.Null = sTID("null");
        PSType.BlendMode = cTID("BlnM");
        PSType.Ordinal = cTID("Ordn");
    };
    Overlay.loadSymbols();
    Overlay.main = function() {
        Overlay();
    };
    Overlay.main();
}

2.3 叠加

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

if (ScriptUI.environment.keyboardState.shiftKey) {
    var idMk = charIDToTypeID("Mk  ");
    var desc17 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref14 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    ref14.putClass(idLyr);
    desc17.putReference(idnull, ref14);
    executeAction(idMk, desc17, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc18 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref15 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref15.putEnumerated(idLyr, idOrdn, idTrgt);
    desc18.putReference(idnull, ref15);
    var idT = charIDToTypeID("T   ");
    var desc19 = new ActionDescriptor();
    var idClr = charIDToTypeID("Clr ");
    var idClr = charIDToTypeID("Clr ");
    var idBl = charIDToTypeID("Bl  ");
    desc19.putEnumerated(idClr, idClr, idBl);
    var idLyr = charIDToTypeID("Lyr ");
    desc18.putObject(idT, idLyr, desc19);
    executeAction(idsetd, desc18, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc20 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref16 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref16.putEnumerated(idLyr, idOrdn, idTrgt);
    desc20.putReference(idnull, ref16);
    var idT = charIDToTypeID("T   ");
    var desc21 = new ActionDescriptor();
    var idNm = charIDToTypeID("Nm  ");
    desc21.putString(idNm, "Blank_Overlay");
    var idLyr = charIDToTypeID("Lyr ");
    desc20.putObject(idT, idLyr, desc21);
    executeAction(idsetd, desc20, DialogModes.NO);
    var idsetd = charIDToTypeID("setd");
    var desc22 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    var ref17 = new ActionReference();
    var idLyr = charIDToTypeID("Lyr ");
    var idOrdn = charIDToTypeID("Ordn");
    var idTrgt = charIDToTypeID("Trgt");
    ref17.putEnumerated(idLyr, idOrdn, idTrgt);
    desc22.putReference(idnull, ref17);
    var idT = charIDToTypeID("T   ");
    var desc23 = new ActionDescriptor();
    var idMd = charIDToTypeID("Md  ");
    var idBlnM = charIDToTypeID("BlnM");
    var idOvrl = charIDToTypeID("Ovrl");
    desc23.putEnumerated(idMd, idBlnM, idOvrl);
    var idLyr = charIDToTypeID("Lyr ");
    desc22.putObject(idT, idLyr, desc23);
    executeAction(idsetd, desc22, DialogModes.NO);
} else {
    function Overlay() {
        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.Layer);
            desc1.putReference(PSString.Null, ref1);
            var desc2 = new ActionDescriptor();
            desc2.putString(PSKey.Name, "D&B_Overlay");
            desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Overlay);
            desc2.putBoolean(PSKey.FillNeutral, true);
            desc1.putObject(PSKey.Using, PSClass.Layer, desc2);
            executeAction(PSEvent.Make, desc1, dialogMode);
        }

        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.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();
        step2();
    }
    cTID = function(s) {
        return app.charIDToTypeID(s);
    };
    sTID = function(s) {
        return app.stringIDToTypeID(s);
    };
    Overlay.loadSymbols = function() {
        var dbgLevel = $.level;
        $.level = 0;
        try {
            PSConstants;
            return;
        } 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() {

            };
        }
        PSClass.Layer = cTID("Lyr ");
        PSEnum.Blue = cTID("Bl  ");
        PSEnum.Overlay = cTID("Ovrl");
        PSEnum.SoftLight = cTID("SftL");
        PSEnum.Target = cTID("Trgt");
        PSEvent.Make = cTID("Mk  ");
        PSEvent.Set = cTID("setd");
        PSKey.Color = cTID("Clr ");
        PSKey.FillNeutral = cTID("FlNt");
        PSKey.Mode = cTID("Md  ");
        PSKey.Name = cTID("Nm  ");
        PSKey.To = cTID("T   ");
        PSKey.Using = cTID("Usng");
        PSString.Null = sTID("null");
        PSType.BlendMode = cTID("BlnM");
        PSType.Ordinal = cTID("Ordn");
    };
    Overlay.loadSymbols();
    Overlay.main = function() {
        Overlay();
    };
    Overlay.main();
}

3.作者寄语

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


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

标签:function,插件,--,charIDToTypeID,idLyr,柔光,var,new,cTID
来源: https://blog.csdn.net/weixin_42247427/article/details/121953860