-1

I'm new to Photoshop scripting and javascript. How can I read via code the image inside the active window in Photoshop CS5-C6 and paste that image into a web page DIV?

FYI I'm a complete newbie to programming. My goal is to build a simple Mac App prototype with a wrapper running a web app inside. That web app needs to connect to Photoshop via TCP and read the image inside the selected window document and then paste it somehow into the web app's html. (Photoshop has feature inside the edit menu called 'remote connections' that converts Photoshop into a server and allows any external applications to read/write stuff inside Photoshop by sending javascript over TCP)

So, how can I:

1) Access Photoshop over TCP via javascript? 2) How can I get the image inside the active Photoshop window and paste into the web app?

4

2 回答 2

0

有一个用于连接到 photoshopConnection 的 python 包装

您可以做的一件事是从 PS 获取实际文件信息,然后将文件本身复制到 webapp 中。我不认为 Photoshop 服务器以您想要的方式支持流数据。

于 2013-08-15T19:00:40.927 回答
0

我可能需要一些额外的信息来更准确地提供帮助,但如果我理解正确,我会说你正在本地机器上运行你的代码。

请贴出你正在使用的开发环境(Visual Studio、eclipse等)

第一种方法 您需要保存 Photoshop 图像并将该文件添加到您的项目中。以防万一,我建议先将图像实际移动到您的项目文件夹中。

因此,如果您将图像保存到“C:/Username/Pictures” - 将其移动到“C:/Documents/Visual Studio 2010/Projects/MyWebPage”

完成后,只需添加一个 IMG 标记和文件路径。如果您将图像移动到项目文件夹中,则路径应该只是文件名:

<div>
    <img src="myPhotoshopImage.gif" alt="Image">
</div>

您可以将任何您喜欢的内容放在alt引号 ("") 中,它不会影响它的工作方式。您还可以通过添加高度宽度(这是可选的)来指定尺寸,如下所示:

<div>
    <img src="myPhotoshopImage.gif" alt="Image" height="260" width="420">
</div>

第二种方法 如果您不想担心管理项目中的图像文件,您可以选择在线托管它们。

首先,将您的想象保存在 Photoshop 中。然后选择图像托管服务。我建议ImageShack可以轻松开始。我还建议创建一个帐户来跟踪所有内容。

登录 ImageShack 并转到“媒体上传”选项卡。单击“浏览”按钮并找到您的图像。单击确定。如果您希望图像与计算机上的外观相同,请确保选中“不调整大小”。最后,点击下一页的“立即上传”和“继续图片链接”。

您会注意到他们已经为您生成了一个 HTML 链接,这将起作用 - 但如果单击它,它也将充当指向 ImageShack 的链接。如果你想避免这种情况,只需遵循相同的模式:

<div>
    <img src="http://img541.imageshack.us/img541/2232/123vm.jpg" alt="Image" height="260" width="420">
</div>

您需要对您希望嵌入图像采取的任何其他操作进行一些研究。W3Schools是一个很好的起点。

编辑- 忘了提...如果你想使用一些 javascript 函数来处理图像,给你的图像一个“id”属性:

<img src="something.jpg" alt="whatever" id="headerImage">

您现在可以通过 javascript 访问图像:

function foo() {
     var myImage = document.getElementById("headerImage");
     myImage.height = 1000;
     myImage.width = 832;
};

此外,如果您遇到任何问题,请确保您的图像保存为通用文件类型(不是 .psd)

于 2013-07-30T01:50:42.743 回答