javascript ExtendScript工具包/实用程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript ExtendScript工具包/实用程序相关的知识,希望对你有一定的参考价值。

/* globals $, app, BridgeTalk */

// Adobe Bridge et al. automation scripts
// 
// ## (Adobe scripting-related) Resources
// 
//  * https://openclassrooms.com/courses/ecrivez-des-scripts-en-extendscript
//  * https://github.com/yearbook/extendscript-api-documentation -> http://yearbook.github.io/esdocs/
//  * https://github.com/ExtendScript/wiki/wiki
//  * https://github.com/fabiantheblind/extendscript-101
//  * https://github.com/bastienEichenberger/extendscript-library
//  * http://jongware.mit.edu/
//  * http://morris-photographics.com/photoshop/tutorials/scripting1.html
//  * http://morris-photographics.com/photoshop/tutorials/scripting2.html
//  * http://morris-photographics.com/photoshop/tutorials/actions.html
//  * http://morris-photographics.com/photoshop/scripts/
//  * http://www.kahrel.plus.com/indesignscripts.html

/**
 * @module EstkUtil
 */
var EstkUtil;
(function (EstkUtil) {
  'use strict';


  function clc() {
    if (app.name === 'ExtendScript Toolkit') {
      return app.clc();
    }
    var estk = BridgeTalk.getSpecifier('estoolkit');
    if (estk) {
      var bt = new BridgeTalk();
      bt.target = estk;
      bt.body = 'app.clc()';
      bt.send();
    }
  }
  EstkUtil.clc = clc;


  function ferr(e) {
    if (!e) {
      return 'An error has occurred!';
    }

    var
      mess = e.number ? 'E#' + e.number : '',
      part = e.fileName || '';

    if (e.line) {
      part += '@' + e.line;
    }

    if (part) {
      mess += ' (' + part + ')';
    }

    return (mess ? mess + ' ' : '') + (e.message || e);
  }
  EstkUtil.ferr = ferr;


  function ln() {
    var args = Array.prototype.slice.call(arguments);
    args.unshift({
      sep: '\r'
    });
    p.apply(null, args);
  }
  EstkUtil.ln = ln;


  function p(opts /*, ...*/ ) {
    var sep, args;
    if (opts && isObject(opts)) {
      sep = opts.separator || opts.sep || ' ';
      args = Array.prototype.slice.call(arguments, 1);
    } else {
      sep = ' ';
      args = Array.prototype.slice.call(arguments);
    }
    $.writeln(args ? args.join(sep) : '');
  }
  EstkUtil.p = p;


  function isObject(val) {
    return val === null ? false : (typeof val === 'object') || (typeof val === 'function');
  }
  EstkUtil.isObject = isObject;


}(EstkUtil || (EstkUtil = {})));

以上是关于javascript ExtendScript工具包/实用程序的主要内容,如果未能解决你的问题,请参考以下文章

Adobe ExtendScript 开发 - 与常规 JavaScript 有何不同?

After Effects / ExtendScript:使用库和导入 .jsx 文件?

哪些 ECMAScript 标准符合 Adob​​e 的 ExtendScript 实施? (如有)

Photoshop Extendscript - 文件被锁定 - 无法保存

如何从 url 下载图像以在 Photoshop 脚本中使用(ExtendScript Toolkit)

Extendscript 的单元测试