问题描述:

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?

网友答案:

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

相关阅读:
Top