admin管理员组文章数量:1537344
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)拼合为一个应用程序,加上辅助一些文件管理、业务逻辑等,可以解决一些比较复杂的图片批处理需求了。
版权声明:本文标题:Adobe Photoshop脚本自动化技术 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726953222a1091605.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论