【问题标题】:Applescript CS5 and CS6 export with save for web will not workApplescript CS5 和 CS6 导出并保存为 Web 将不起作用
【发布时间】:2014-05-16 00:40:26
【问题描述】:

我无计可施。我已经尝试了所有变体来让这个脚本工作。我得到的错误是 Adob​​e Photoshop CS6 出错:无法获取当前文档。突出显示的脚本错误是我的“在文件 newFileName.. 中导出”块。我尝试将别名放在不同的位置,使用文件,而不是使用文件。我也收到此错误消息,但实际脚本似乎在“将 docName 设置为 docRef 的名称”之后立即停止工作

基本上我只是从另一个运行良好的脚本中复制了这段代码,只是将保存这个文件...更改为导出这个文件...

-- set the folders that you want to use
set inputFolder to choose folder with prompt "Choose the folder of images to downsize."
set pathToDesktop to (path to desktop folder as string)
set outputFolder to pathToDesktop & "PhotoshopRetina:"


tell application "Finder"
set filesList to files in folder inputFolder
if not (exists folder outputFolder) then
    make new folder at desktop with properties {name:"PhotoshopRetina"}
end if
end tell
with timeout of 86400 seconds
tell application "Adobe Photoshop CS6"
    set display dialogs to never
    close every document saving no
end tell

repeat with aFile in filesList

    tell application "Finder"
        -- The step below is important because the 'aFile' reference as    returned by
        -- Finder associates the file with Finder and not Photoshop. By converting
        -- the reference below 'as alias', the reference used by 'open' will be
        -- correctly handled by Photoshop rather than Finder.
        set theFile to aFile as string
        set theFileName to name of aFile
        set theFileInfo to info for alias theFile
        if kind of theFileInfo is "Adobe Photoshop JPEG file" then
            my retinaDisplay(theFile)
        end if
    end tell

end repeat
end timeout
end

on retinaDisplay(theFile)

tell application "Adobe Photoshop CS6"
    open alias theFile

    set docRef to the current document
    -- Convert the document to a document mode that supports saving as jpeg
    if (mode of docRef is not RGB) then
        change mode docRef to RGB
    end if

    tell docRef

        set color profile kind to none

    end tell

    set infoRef to get info of docRef
    set docName to name of docRef
    set docBaseName to getBaseName(docName) of me

    set newFileName to (my outputFolder as string) & docBaseName & ".jpg"



    tell current document
        export in file newFileName as save for web with options {class:save for web export options, web format:JPEG, embed color profile:false, quality:45} with copying
    end tell

    close current document without saving

end tell
end retinaDisplay

-- Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
    if (item idx of fName = ".") then
        set baseName to (items 1 thru (idx - 1) of fName) as string
        exit repeat
    end if
end repeat
return baseName
end getBaseName
end

【问题讨论】:

  • >> 但实际脚本似乎在“将 docName 设置为 docRef 的名称”Events 输出选项卡中看到了什么?并不是说我知道它为什么会有所作为,而是尝试使用标准对象说明符 document 1 代替 current document

标签: applescript export photoshop


【解决方案1】:

如果我在 Photoshop 中打开图像,我可以毫无错误地运行此代码。

set f to (path to desktop as text) & "test.jpg"

tell application "Adobe Photoshop CS6"
    tell current document
        export in file f as save for web
    end tell
end tell

但是,如果我另外添加您的“带选项”代码,则会收到您的错误。我什至不知道“复制”部分是什么。我认为这对 Photoshop 没有任何意义。所以问题不在于“当前文档”。问题在于您的选择。你一定是做错了。

祝你好运。

【讨论】:

  • 谢谢,我是用 PS 和 Acrobat 完成的。
猜你喜欢
  • 2022-08-13
  • 2023-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多