AppleScript图像事件无法获取asDB类

AppleScript图像事件无法获取asDB类,applescript,image-events,Applescript,Image Events,想要了解更多关于Mac的图像事件,我正在尝试学习如何将文件从一种类型保存到另一种类型。例如,如果我有一个名为foobar.BMP的BMP图像,我想学习如何将其保存为foobar.jpg,但在我的处理程序中,我遇到了一个错误: Image Events出现错误:无法获取«class asDB»id(应用程序 图像“foobar.bmp”的“图像事件”) 我的处理程序中的代码: tell application "Finder" set directory to (choose folder

想要了解更多关于Mac的图像事件,我正在尝试学习如何将文件从一种类型保存到另一种类型。例如,如果我有一个名为
foobar.BMP
的BMP图像,我想学习如何将其保存为
foobar.jpg
,但在我的处理程序中,我遇到了一个错误:

Image Events出现错误:无法获取«class asDB»id(应用程序 图像“foobar.bmp”的“图像事件”)

我的处理程序中的代码:

tell application "Finder"
    set directory to (choose folder with prompt "Please select a directory.")
    set someImages to (files of folder directory where name extension is "bmp") as alias list
    repeat with someImage in someImages
        tell application "Image Events"
            launch
            set workingImage to open someImage
            save workingImage as JPEG in directory
            close workingImage
        end tell
    end repeat
end tell
我测试了
保存
是否需要POSIX路径,而不是别名路径:

set directoryPosix to (POSIX path of directory)
并更改了
保存

save workingImage as JPEG in directoryPosix

但我仍然产生同样的错误,我不明白为什么。代码可以工作,但只是抛出了一个错误,搜索后我无法找到一个解决方案。我已经知道如何使用ImageMagick使用Bash实现这一点,我可以使用AppleScript和SIPs实现这一点,但我想了解更多有关图像事件的信息。我犯了什么错误而抛出了错误?如果我的操作系统是最新的并且运行的是Yosemite版本10.10.5,则需要指定新文件的完整(HFS或POSIX)路径,而不是目标文件夹的
别名
说明符:

set directory to (choose folder with prompt "Please select a directory.") as text
tell application "Finder" to set someImages to (files of folder directory where name extension is "bmp") as alias list

tell application "Image Events"
    launch
    repeat with someImage in someImages
        set workingImage to open someImage
        set fileName to name of workingImage
        set newFilePath to directory & text 1 thru -4 of fileName & "jpg"
        save workingImage as JPEG in newFilePath
        close workingImage
    end repeat
end tell

您需要指定新文件的完整(HFS或POSIX)路径,而不是目标文件夹的
别名
说明符:

set directory to (choose folder with prompt "Please select a directory.") as text
tell application "Finder" to set someImages to (files of folder directory where name extension is "bmp") as alias list

tell application "Image Events"
    launch
    repeat with someImage in someImages
        set workingImage to open someImage
        set fileName to name of workingImage
        set newFilePath to directory & text 1 thru -4 of fileName & "jpg"
        save workingImage as JPEG in newFilePath
        close workingImage
    end repeat
end tell