Applescript —找不到捆绑资源

发布于 2024-12-22 16:57:47 字数 689 浏览 2 评论 0原文

我正在尝试为 Photoshop 编写一个 Applescript Droplet,用于调整多张照片的大小并为其添加水印。我想捆绑水印图像并保存为应用程序,以便我可以在我的组织内分发它,但我似乎无法让脚本查看捆绑的资源。

我将“watermark.png”图像拖到“捆绑内容”侧边栏,并使用以下文件处理语句:

on process_item(this_item)
    set myPath to alias this_item as text
    tell application "Adobe Photoshop CS5.1"
        open file myPath
        set thisDocument to current document
        set ruler units of settings to pixel units
        resize image thisDocument width 640
        set wmPath to path to resource "watermark.png"
        open file wmPath
    end tell
end process_item

但我总是收到以下错误:

Resource not found.

我是否必须做一些特殊的事情来确保脚本可以找到捆绑的内容资源?

I'm trying to write an Applescript droplet for Photoshop that resizes and watermarks multiple photos. I want to bundle the watermark images and save as an app so I can distribute it within my organization, but I can't seem to get the script to see the bundled resource.

I dragged my "watermark.png" image to the "Bundle Contents" sidebar, and am using the following file processing statements:

on process_item(this_item)
    set myPath to alias this_item as text
    tell application "Adobe Photoshop CS5.1"
        open file myPath
        set thisDocument to current document
        set ruler units of settings to pixel units
        resize image thisDocument width 640
        set wmPath to path to resource "watermark.png"
        open file wmPath
    end tell
end process_item

but I always get the following error:

Resource not found.

Do I have to do something special to make sure the script can find the bundled resources?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作妖 2024-12-29 16:57:47

这是因为您要求应用程序“Photoshop”查找资源。它不知道该怎么做。

要解决此问题,请将行 set wmPath to path to resource "watermark.png" 移到块 tell application 之外(例如,在行 tell 之前)应用程序“Adobe Photoshop CS5.1”),
或将其更改为:

tell me to set wmPath to path to resource "watermark.png"

It is because you are asking the application "Photoshop" to find the resource. It does not know how to do this.

To fix this, either move the line set wmPath to path to resource "watermark.png" outside of the block tell application (for example, before the line tell application "Adobe Photoshop CS5.1"),
or change it to:

tell me to set wmPath to path to resource "watermark.png"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文