【问题标题】:How to load an image in active document? (Photoshop Scripting)如何在活动文档中加载图像? (Photoshop脚本)
【发布时间】:2011-02-12 16:34:27
【问题描述】:

我是 Photoshop 脚本的新手。

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

谢谢

【问题讨论】:

    标签: photoshop photoshop-script


    【解决方案1】:

    您可以打开 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

    【讨论】:

      猜你喜欢
      • 2015-09-10
      • 2013-10-23
      • 2016-12-24
      • 2014-12-24
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-10
      相关资源
      最近更新 更多