粘贴到位Photoshop脚本 [英] Paste In Place Photoshop Script

查看:203
本文介绍了粘贴到位Photoshop脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为您那里的Photoshop脚本编写者(javascript),我编写了一个脚本,用于复制合并图像区域并将其粘贴到另一个文档中.让我感到困扰的是,粘贴的图像粘贴到屏幕的中间,而不粘贴到选择坐标.

For you Photoshop scripters (javascript) out there, I've written a script that copy merges an image area and pastes it into another document. The thing that bothers me is the fact that the image that is pasted is pasted to the middle of the screen and not to the selection coordinates.

所以第一个图像是2000px x 2000px,我使用脚本复制合并了500px x 500px的区域,然后将其粘贴到另一个500px x 500px的文档中.唯一的问题是粘贴的图像被向下放入文档的中间区域,因此,如果复制的区域具有一些透明像素,则有时无法将其粘贴到正确的位置.

So the first image is say 2000px by 2000px and I use my script to copy merge an area of 500px by 500px and then paste that to another document that is 500px by 500px. The only problem is the pasted image is plopped down into the smack middle of the document so if the copied area has some transparent pixels sometimes it isn't pasted to the correct location.

Photoshop具有一个称为粘贴到位"的功能,您可以通过编辑">粘贴特别">粘贴到位"功能来解决,这对我来说当然解决了这个问题,因为我需要知道粘贴到位的javascript代码,以便从我的脚本中做到这一点.

Photoshop has a function called Paste In Place which you can get to by Edit>Paste Special>Paste In Place which of course solves that problem the issue for me is I need to know the javascript code for Paste In Place so it can do that from my script.

有人知道吗?

推荐答案

将这些变量添加到代码的开头:

Add these variable to the begining of your code:

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

用于粘贴的功能是:

function pasteInPlace(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putBoolean(sTID("inPlace"), true);
    desc1.putEnumerated(cTID('AntA'), cTID('Annt'), cTID('Anno'));
    executeAction(cTID('past'), desc1, dialogMode);
  };

将该功能添加到脚本的最后.

Add the function to the very end of your script.

然后使用:

pasteInPlace();

在您的代码中调用该函数.

In your code to call the function.

我是通过使用xtools actionfileTOJavascript.jsx

I got this from using xtools actionfileTOJavascript.jsx

希望这会有所帮助

这篇关于粘贴到位Photoshop脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆