如何在活动文档中加载图像? (Photoshop脚本)

时间:2010-04-27 03:02:45

标签: photoshop photoshop-script

我不熟悉photoshop脚本。

我想将图像图像(从我的硬盘上)加载到活动文档中作为具有定位的新图层。如何才能做到这一点?有人可以分享一下代码吗?

由于

1 个答案:

答案 0 :(得分:9)

您可以打开Photoshop文件对话框来搜索图像并将其添加到图层

file = app.openDialog();//opens dialog,choose one image

if(file[0]){ //if you have chosen an image
   app.load(file[0]); //load it into documents
   backFile= app.activeDocument; //prepare your image layer as active document
   backFile.resizeImage(width,height); //resize image into given size i.e 640x480
   backFile.selection.selectAll();
   backFile.selection.copy(); //copy image into clipboard
   backFile.close(SaveOptions.DONOTSAVECHANGES); //close image without saving changes
   doc.paste(); //paste selection into your document
   doc.layers[0].name = "BackgroundImage"; //set your layer's name
}

有一个使用photoshop javascript扩展名(.jsx)制作日历的好例子。

请检查here