How to load an image in active document? (Photoshop Scripting)

旧街凉风 提交于 2019-12-21 04:36:12

问题


I am new to photoshop scripting.

I want to load an image image (from my hard disk) into the active document as a new layer with positioning. How can this be done? Can somebody please share the code?

Thanks


回答1:


You can open Photoshop File Dialog for searching your image and adding that into a layer

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
}

There is a good example of making a calendar with photoshop javascript extension (.jsx).

Please check that here



来源:https://stackoverflow.com/questions/2718443/how-to-load-an-image-in-active-document-photoshop-scripting

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