ps锐化滤镜组(Photoshop插件-全尺寸锐化-网页锐化-脚本开发-PS插件)
ps锐化滤镜组(Photoshop插件-全尺寸锐化-网页锐化-脚本开发-PS插件)cTID = function (s) { return app.charIDToTypeID(s); }; sTID = function (s) { return app.stringIDToTypeID(s); }; // //==================== High Pass ForWeb Sharpen ============== // function HighPassForWebSharpen() { // Make function step1(enabled withDialog) { if (enabled != undefined && !enabled) return; var dialogMode = (withDialog ? DialogModes.ALL
PS是一款栅格图像编辑软件,模块众多。提供了脚本,动态连接库等多种扩展机制,本文演示如何通过脚本实现全尺寸锐化和网页锐化相关功能,展示从互联网收集而来的一个小插件,供大家学习交流,请勿用于商业用途。
1.插件界面本文界面是一系列功能的一部分,将逐步展示,但是功能界面是共同的,如下图所示:
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
cTID = function (s) {
return app.charIDToTypeID(s);
};
sTID = function (s) {
return app.stringIDToTypeID(s);
};
//
//==================== High Pass Sharpen Full Size ==============
//
function HighPassSharpenFullSize() {
// Layer Via Copy
function step1(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('copyToLayer') undefined 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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
desc1.putReference(cTID('null') ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(cTID('Md ') cTID('BlnM') cTID('SftL'));
desc1.putObject(cTID('T ') cTID('Lyr ') desc2);
executeAction(cTID('setd') desc1 dialogMode);
};
// High Pass
function step3(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('Rds ') cTID('#Pxl') 10);
executeAction(sTID('highPass') desc1 dialogMode);
};
// Hide
function step4(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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null') list1);
executeAction(cTID('Hd ') desc1 dialogMode);
};
// Show
function step5(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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null') list1);
executeAction(cTID('Shw ') desc1 dialogMode);
};
var errors = "";
try {
step1();
} catch (e) {
errors = e
}
; // Layer Via Copy
try {
step2();
} catch (e) {
errors = e
}
; // Set
try {
step3();
} catch (e) {
errors = e
}
; // High Pass
try {
step4();
} catch (e) {
errors = e
}
; // Hide
try {
step5();
} catch (e) {
errors = e
}
; // Show
};
HighPassSharpenFullSize.main = function () {
HighPassSharpenFullSize();
};
HighPassSharpenFullSize.main();
2.2.网页锐化
大家可通过源代码阅读,来掌握相关技巧,源代码如下:
cTID = function (s) {
return app.charIDToTypeID(s);
};
sTID = function (s) {
return app.stringIDToTypeID(s);
};
//
//==================== High Pass ForWeb Sharpen ==============
//
function HighPassForWebSharpen() {
// 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(cTID('Dcmn'));
desc1.putReference(cTID('null') ref1);
desc1.putString(cTID('Nm ') "High Pass");
var ref2 = new ActionReference();
ref2.putEnumerated(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
desc1.putReference(cTID('Usng') ref2);
desc1.putInteger(cTID('Vrsn') 5);
executeAction(cTID('Mk ') desc1 dialogMode);
};
// Image Size
function step2(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('Wdth') cTID('#Pxl') 960);
desc1.putBoolean(sTID("scaleStyles") true);
desc1.putBoolean(cTID('CnsP') true);
desc1.putEnumerated(cTID('Intr') cTID('Intp') sTID("bicubicSmoother"));
executeAction(sTID('imageSize') desc1 dialogMode);
};
// Layer Via Copy
function step3(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(sTID('copyToLayer') undefined 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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
desc1.putReference(cTID('null') ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(cTID('Md ') cTID('BlnM') cTID('SftL'));
desc1.putObject(cTID('T ') cTID('Lyr ') desc2);
executeAction(cTID('setd') desc1 dialogMode);
};
// High Pass
function step5(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(cTID('Rds ') cTID('#Pxl') 1.4);
executeAction(sTID('highPass') desc1 dialogMode);
};
// Hide
function step6(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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null') list1);
executeAction(cTID('Hd ') desc1 dialogMode);
};
// Show
function step7(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(cTID('Lyr ') cTID('Ordn') cTID('Trgt'));
list1.putReference(ref1);
desc1.putList(cTID('null') list1);
executeAction(cTID('Shw ') desc1 dialogMode);
};
// Make
function step8(enabled withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putClass(cTID('Nw ') cTID('Chnl'));
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Chnl') cTID('Chnl') cTID('Msk '));
desc1.putReference(cTID('At ') ref1);
desc1.putEnumerated(cTID('Usng') cTID('UsrM') cTID('RvlA'));
executeAction(cTID('Mk ') desc1 dialogMode);
};
var errors = "";
try {
step1();
} catch (e) {
errors = e
}
; // Make
try {
step2();
} catch (e) {
errors = e
}
; // Image Size
try {
step3();
} catch (e) {
errors = e
}
; // Layer Via Copy
try {
step4();
} catch (e) {
errors = e
}
; // Set
try {
step5();
} catch (e) {
errors = e
}
; // High Pass
try {
step6();
} catch (e) {
errors = e
}
; // Hide
try {
step7();
} catch (e) {
errors = e
}
; // Show
try {
step8();
} catch (e) {
errors = e
}
; // Make
};
HighPassForWebSharpen.main = function () {
HighPassForWebSharpen();
};
HighPassForWebSharpen.main();
3.代码转执行
使用记事本或者notepad 等文本编辑器,将代码拷贝至文本文件,然后修改后缀名为js或者jsx,最后再PS软件菜单文件》脚本》浏览,点执行即可,也可以将脚本放在预设文件夹内,会显示再脚本下的二级子菜单。如下图所示:
代码长度过长,如需全部项目或有疑问,请留言。
提示: 作者联系方式
提示: 插件开发流程 - 知乎