如何在活动文档中加载图像? (Photoshop脚本) [英] How to load an image in active document? (Photoshop Scripting)

查看:89
本文介绍了如何在活动文档中加载图像? (Photoshop脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Photoshop脚本的新手.

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?

谢谢

推荐答案

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

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
}

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

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

请在此处

这篇关于如何在活动文档中加载图像? (Photoshop脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆