ps后期插件调色教程(Photoshop插件-锐化-高反差保留仅边缘-脚本开发-PS插件)

PS是一款栅格图像编辑软件,模块众多。提供了脚本,动态连接库等多种扩展机制,本文演示如何通过脚本实现高反差保留仅边缘相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。

1.插件界面

  本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:

ps后期插件调色教程(Photoshop插件-锐化-高反差保留仅边缘-脚本开发-PS插件)(1)

2.关键代码

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

// //==================== HP only Edges ============== // function HPonlyEdges() { // 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(); desc2.putString(PSKey.Name, "BW MaxW"); desc2.putUnitDouble(PSKey.Opacity, PSUnit.Percent, 0); var desc3 = new ActionDescriptor(); desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault); desc3.putInteger(PSKey.Red, 40); desc3.putInteger(PSEnum.Yellow, 60); desc3.putInteger(PSKey.Green, 40); desc3.putInteger(PSKey.Cyan, 60); desc3.putInteger(PSKey.Blue, 20); desc3.putInteger(PSKey.Magenta, 80); desc3.putBoolean(PSString.useTint, false); var desc4 = new ActionDescriptor(); desc4.putDouble(PSKey.Red, 225.000457763672); desc4.putDouble(PSKey.Green, 211.000671386719); desc4.putDouble(PSKey.Blue, 179.001159667969); desc3.putObject(PSString.tintColor, PSClass.RGBColor, desc4); desc2.putObject(PSKey.Type, PSEnum.BlackAndWhite, desc3); desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2); executeAction(PSEvent.Make, desc1, dialogMode); }; // Set 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.AdjustmentLayer, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindFactory); desc2.putInteger(PSKey.Red, 100); desc2.putInteger(PSEnum.Yellow, 100); desc2.putInteger(PSKey.Green, 100); desc2.putInteger(PSKey.Cyan, 100); desc2.putInteger(PSKey.Blue, 100); desc2.putInteger(PSKey.Magenta, 100); var desc3 = new ActionDescriptor(); desc3.putDouble(PSKey.Red, 224.976655840874); desc3.putDouble(PSKey.Green, 210.976656675339); desc3.putDouble(PSKey.Blue, 178.976658582687); desc2.putObject(PSString.tintColor, PSClass.RGBColor, desc3); desc1.putObject(PSKey.To, PSEnum.BlackAndWhite, desc2); executeAction(PSEvent.Set, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); var ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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 ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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.Layer, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); var ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Move 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.Layer, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); var ref2 = new ActionReference(); ref2.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Front); desc1.putReference(PSKey.To, ref2); executeAction(PSEvent.Move, desc1, dialogMode); }; // Duplicate 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.putEnumerated(PSClass.Document, PSType.Ordinal, PSEnum.First); desc1.putReference(PSString.Null, ref1); desc1.putString(PSKey.Name, "CMYK"); executeAction(PSEvent.Duplicate, desc1, dialogMode); }; // Flatten Image function step15(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); executeAction(sTID('flattenImage'), undefined, dialogMode); }; // Convert to Profile 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.Document, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); desc1.putString(PSKey.To, "Coated FOGRA39 (ISO 12647-2:2004)"); desc1.putEnumerated(PSKey.Intent, PSKey.Intent, PSEnum.Image); desc1.putBoolean(PSKey.MapBlack, true); desc1.putBoolean(PSKey.Dither, false); desc1.putInteger(PSKey.ShadowMode, -1); executeAction(sTID('convertToProfile'), desc1, dialogMode); }; // Make 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.putClass(PSClass.Layer); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putString(PSKey.Name, "Merged to Work"); desc1.putObject(PSKey.Using, PSClass.Layer, desc2); executeAction(PSEvent.Make, desc1, dialogMode); }; // Select 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.putOffset(PSClass.Document, -1); desc1.putReference(PSString.Null, ref1); executeAction(PSEvent.Select, 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.Layer); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putString(PSKey.Name, "Black Channel"); desc1.putObject(PSKey.Using, PSClass.Layer, desc2); executeAction(PSEvent.Make, desc1, dialogMode); }; // Apply Image function step20(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); var desc2 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.Black); ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Merged); ref1.putName(PSClass.Document, "CMYK"); desc2.putReference(PSKey.To, ref1); desc1.putObject(PSKey.With, PSClass.Calculation, desc2); executeAction(sTID('applyImageEvent'), 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.Layer, PSType.Ordinal, PSEnum.Target); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Screen); desc1.putObject(PSKey.To, PSClass.Layer, desc2); executeAction(PSEvent.Set, desc1, dialogMode); }; // Curves function step22(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); desc1.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindCustom); var list1 = new ActionList(); var desc2 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(PSClass.Channel, PSType.Ordinal, PSEnum.Target); desc2.putReference(PSClass.Channel, ref1); var list2 = new ActionList(); var desc3 = new ActionDescriptor(); desc3.putDouble(PSKey.Horizontal, 0); desc3.putDouble(PSKey.Vertical, 96); list2.putObject(PSClass.Point, desc3); var desc4 = new ActionDescriptor(); desc4.putDouble(PSKey.Horizontal, 64); desc4.putDouble(PSKey.Vertical, 112); list2.putObject(PSClass.Point, desc4); var desc5 = new ActionDescriptor(); desc5.putDouble(PSKey.Horizontal, 255); desc5.putDouble(PSKey.Vertical, 224); list2.putObject(PSClass.Point, desc5); desc2.putList(PSKey.Curve, list2); list1.putObject(PSClass.CurvesAdjustment, desc2); desc1.putList(PSKey.Adjustment, list1); executeAction(PSEvent.Curves, desc1, dialogMode); }; // Select 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.Backward); desc1.putReference(PSString.Null, ref1); desc1.putBoolean(PSKey.MakeVisible, false); executeAction(PSEvent.Select, 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.putUnitDouble(PSKey.Opacity, PSUnit.Percent, 100); desc1.putObject(PSKey.To, PSClass.Layer, desc2); executeAction(PSEvent.Set, desc1, dialogMode); }; // Select function step25(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.Forward); desc1.putReference(PSString.Null, ref1); desc1.putBoolean(PSKey.MakeVisible, false); executeAction(PSEvent.Select, desc1, dialogMode); }; // Make 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.putClass(PSClass.Layer); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putString(PSKey.Name, "BW MaxW & Black Channel"); desc1.putObject(PSKey.Using, PSClass.Layer, desc2); executeAction(PSEvent.Make, desc1, dialogMode); }; // Select 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.putOffset(PSClass.Document, 1); desc1.putReference(PSString.Null, ref1); executeAction(PSEvent.Select, desc1, dialogMode); }; // Close function step28(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); desc1.putEnumerated(PSKey.Saving, PSType.YesNo, PSEnum.No); executeAction(PSEvent.Close, desc1, dialogMode); }; // Apply Image function step29(enabled, withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO); var desc1 = new ActionDescriptor(); var desc2 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated(PSClass.Channel, PSClass.Channel, PSEnum.RGB); ref1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Merged); desc2.putReference(PSKey.To, ref1); desc1.putObject(PSKey.With, PSClass.Calculation, desc2); executeAction(sTID('applyImageEvent'), desc1, dialogMode); }; // Make 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.putClass(PSClass.AdjustmentLayer); desc1.putReference(PSString.Null, ref1); var desc2 = new ActionDescriptor(); desc2.putString(PSKey.Name, "Curves Control HP"); desc2.putBoolean(PSKey.Group, true); var desc3 = new ActionDescriptor(); desc3.putEnumerated(PSString.presetKind, PSString.presetKindType, PSString.presetKindDefault); desc2.putObject(PSKey.Type, PSEvent.Curves, desc3); desc1.putObject(PSKey.Using, PSClass.AdjustmentLayer, desc2); executeAction(PSEvent.Make, desc1, dialogMode); };

3.代码转执行

  使用记事本或者notepad 等文本编辑器,将代码拷贝至文本文件,然后修改后缀名为js或者jsx,最后再PS软件菜单文件》脚本》浏览,点执行即可,也可以将脚本放在预设文件夹内,会显示再脚本下的二级子菜单。如下图所示:

ps后期插件调色教程(Photoshop插件-锐化-高反差保留仅边缘-脚本开发-PS插件)(2)

4.作者答疑

文章引用至 作者联系方式

文章引用至 插件开发流程 - 知乎

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页