我需要将一些图像分组到一个 Photoshop 文件中,并尝试寻找更优化的路径。我知道我可以使用 applescript 来做这样的事情。
tell application id "com.adobe.Photoshop"
activate
open file (CurrentImg)
duplicate layer 1 of current document to end of NewDocRef
end tell
-- CurrentImg is some file path and NewDocRef is a path to some other open document
我可以使用 open 一次打开每个图像并将其移动到一个文档中。我的问题是,是否有人有更好的方法将图像直接放入打开的文档中。寻找仅将图像拖入的效果。我愿意使用 javascript 函数来完成此操作。 (我不懂 JavaScript,但我可以设法大部分理解我读到的内容。)
最佳答案
我用 ExtendScript 编写的。 在 Osx Photoshop 2014 CC 上测试
// based on this stackoverflow
// http://stackoverflow.com/a/2780624/1770432
var main = function(arguments, body) {
if (app.documents.length < 1) {
// abort no file to place imports in
return;
}
// filter does not work on OSX
var files = File.openDialog("Select your files to place", "*.*", true);
if (files.length < 1 || files === null) {
// abort
// nothing selected or canceld
return;
} else {
// got something
var doc = app.activeDocument;
// loop all files
for (var i = 0; i < files.length; i++) {
// we use a try catch to sort out files Photoshop cant handle
try {
var curr_file = app.open(files[i]); // one of them
curr_file.selection.selectAll();
curr_file.selection.copy();
curr_file.close(SaveOptions.DONOTSAVECHANGES);
doc.paste();
} catch (e) {
// need to skip files Photoshop can't open
// could also be done via a file filter
continue;
}
}
}
}
main();
关于javascript - 将图像放入当前打开的 Photoshop 文档 (applescript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26180241/