Paste In Place Photoshop Script

十年热恋 提交于 2019-12-12 02:52:27

问题


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.

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 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.

Anyone know?


回答1:


Add these variable to the begining of your code:

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

The function used to paste in place is:

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.

Then use:

pasteInPlace();

In your code to call the function.

I got this from using xtools actionfileTOJavascript.jsx

Hope this helps



来源:https://stackoverflow.com/questions/25904603/paste-in-place-photoshop-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!