【问题标题】:How can I select pictures from iPhoto into my Cocoa application using Applescript / Automator如何使用 Applescript / Automator 从 iPhoto 中选择图片到我的 Cocoa 应用程序中
【发布时间】:2013-11-05 18:09:14
【问题描述】:

我有一个图像编辑 Cocoa Mac 应用程序,它需要一些图像文件(jpeg、png、tiff、gif 等)作为输入。我想在我的应用程序中为用户提供一个按钮,以便从 iPhoto 获取这些输入图像文件。

我希望在用户单击此按钮时打开带有 iPhoto 图片的对话框/弹出窗口。然后用户可以在此对话框/弹出窗口中选择一些图片。在选择后关闭对话框时,我想获取所选图片的路径。

请建议我如何实现这一目标。

由 Abizern 在对我的回答发表评论后编辑

我宁愿不使用第三方框架 - 有没有办法在我的应用程序中使用 Applescript 或 Automator 工作流程来做到这一点?

【问题讨论】:

    标签: applescript automator iphoto


    【解决方案1】:

    查看Karelia iMedia Browser,您可以将其作为框架添加到您的项目中。

    不仅是 iPhoto 图片,还有硬盘上的图片,以及来自 Flickr 的图片。

    【讨论】:

    • 我不想使用第三方框架,这不是很容易使用苹果脚本/自动化工作流程吗
    • 那为什么要在问题上加上objective-c和Cocoa标签呢?
    【解决方案2】:

    这是一个脚本,它会弹出 iPhoto 本身并允许用户选择一些照片然后继续。希望您的程序可以为用户提供一种更优雅的无模式方式来表示他们已完成。

    tell application "iPhoto"
        activate
    
        display alert "After you click OK, you will have 10 seconds to select some photos or albums"
        delay 10
    
        set paths to {}
        repeat with s in (get selection)
            set i to properties of s
            if class of i is album then
                repeat with p in photos of album (name of i)
                    copy image path of p to end of paths
                end repeat
            else if class of i is photo then
                copy image path of i to end of paths
            end if
        end repeat
    
        log paths
    end tell
    

    【讨论】:

      猜你喜欢
      • 2011-11-17
      • 1970-01-01
      • 2010-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      相关资源
      最近更新 更多