是否可能使用Photoshop的脚本功能,从Photoshop上传图像(例如,导出为jpeg格式的打开图像)到某个网络位置 - REST服务、FTP等?例如 - 我在Photoshop中打开一张图片,然后执行一些特殊脚本,将其导出版本发送到Web上的某个地方。我看到过类似于这样的东西,但它使用自动生成的批处理文件,在Windows上执行ftp命令。如果可能的话,我想使用更美观的东西。或者也许有一些信息可以知道如何制作一个简单的插件,只用于此任务。谢谢。
function sendDataToServer(data) {
var socket = new Socket(),
port = 80,
domain = "www.example.com",
page = "/path/to/file.php",
bin;
if(socket.open(domain + ":" + port,"binary")) {
socket.write("GET http://" + domain + page + "?data=" + data + " HTTP/1.0\n\n");
bin = socket.read(9999999);
alert(bin);
socket.close();
}
}
function getLine(html){
var line = "", i = 0;
for (; html.charCodeAt(i) != 10; i++){ // finding line end
line += html[i] ;
}
return line;
}
getLine
方法剥离标头:function removeHeaders(binary){
var bContinue = true, // flag for finding end of header
line = "",
nFirst = 0,
count = 0;
while (bContinue) {
line = getLine(binary) ; // each header line
bContinue = line.length >= 2 ; // blank header == end of header
nFirst = line.length + 1 ;
binary = binary.substr(nFirst) ;
}
return binary;
}
Photoshop的API不允许网络访问。它们只控制Photoshop并且仅限于在Photoshop中可以执行的用户操作。
我建议使用Automator或其他外部脚本语言来后处理Photoshop的输出。
可能是使用JavaScript在Photoshop中:
http://www.adobe.com/devnet/bridge/pdfs/javascript_tools_guide_cs3.pdf