adobe脚本的框架_Adobe Photoshop脚本自动化技术

Adobe Photoshop脚本自动化技术是广泛采用的一种技术,它和Adobe Photoshop插件开发不是一个东西。基于PS SDK的插件开发主要是在PS内部提供一些复杂的、高性能的图片处理工具,而PS脚本自动化技术则多用于图片的批处理。

在Adobe Photoshop的安装目录下,有一个Scripting文件夹,里面包含了PS脚本自动化技术的文档和参考脚本样例。

其中打开文档的vbs脚本内容如下:

' Copyright 2002-2008. Adobe Systems, Incorporated. All rights reserved.

' This script demonstrates how to open a Photoshop document from the samples folder

Option Explicit

Dim appRef

Dim docRef

Dim fileName

Dim strSamples

Dim strLayerComps

Dim strLocString

Dim strArg

Set appRef = CreateObject( "Photoshop.Application" )

appRef.BringToFront

strSamples = "$$$/LocalizedFilenames.xml/SourceDirectoryName/id/Extras/[LOCALE]/[LOCALE]_Samples/value=Samples"

strArg = Array(strSamples)

Call getLocString(strSamples)

strLayerComps = "$$$/LocalizedFilenames.xml/SourceFileName/id/Extras/[LOCALE]/[LOCALE]_Samples/Layer_Comps.psd/value=Layer Comps.psd"

strArg = Array(strLayerComps)

Call getLocString(strLayerComps)

fileName = appRef.Path & "\" & strSamples & "\" & strLayerComps

Set docRef = appRef.Open( fileName )

MsgBox "Open Document complete"

' ===============================================

' getLocString functions

' ===============================================

' on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details

Function getLocString(strLocString)

Dim objWshShell

Dim myScriptPath

Dim myFSO

Dim strJSXFile

Set objWshShell = WScript.CreateObject("WScript.Shell")

myScriptPath = objWshShell.CurrentDirectory

Set myFSO = CreateObject("Scripting.FileSystemObject")

strJSXFile = myScriptPath + "\localize.jsx"

strLocString = appRef.DoJavaScriptFile(strJSXFile,Array(strLocString),1)

End Function

转换为VC代码如下:

CApplication m_app;

if(!m_app.CreateDispatch("Photoshop.Application"))

{

MessageBox("PS初始化失败");

PostQuitMessage(0);

}

m_app.Open("D:\\1.psd"); 在PS中进行脚本录制,完成后,在采用编码的方式将录制的多个脚本(一般为jsx)拼合为一个应用程序,加上辅助一些文件管理、业务逻辑等,可以解决一些比较复杂的图片批处理需求了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值