获取iPhoto以增强数千张照片?

时间:2011-04-30 02:42:56

标签: applescript iphoto

我发现我的iPhoto图库中有数千张照片没有合适的图标。我已经尝试重建数据库,但没有奏效。但是,一种可行的技术就是单击“编辑”,然后单击“增强”按钮。

我发现如果我编辑系列中的第一张照片,我可以通过在“增强”按钮和右箭头按钮之间来回切换来修复它们。

有没有办法实现自动化?

1 个答案:

答案 0 :(得分:1)

我没有那么多地使用iPhoto,但我已经使用了AppleScript很长一段时间了。我猜测Enhance按钮位于Edit菜单下方。如果那是真的,那么你可以......

tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1

你说你有成千上万张需要增强的照片。 AppleScript非常适合做这样的事情。要完全自动化(加载图像并增强它们),你可以使用一个Droplet,如下所示:

on open the_images
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images as alias --the current image
        --Verify that the file is actually an image and not just a random file
        tell application "Finder"
            if (this_image) as string does not end with ":" then --a folder, cannot use
                if the name extension of this_image is in {"jpg","tif","gif","png","psd"} then --add additional extensions as needed
                    --This is an image, so enhance it
                    my enhance(this_image)
                else
                    display dialog "The file " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
                end if
            else
                display dialog "The folder " & name of this_image & " is not an image. It cannot be enhanced." buttons{"OK"} default button 1
            end if
        end tell
    end repeat
end open

on enhance(this_image)
    tell application "iPhoto"
        activate
        open this_image
    end tell
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
    tell application "iPhoto" to close this_image
end enhance

编辑:以上代码无法使用(我没有删除它以显示其他人不应该做的事情),但这个代码应该......

tell application "iPhoto"
    set the_images to (get the selection) as list
    repeat with i from 1 to the count of the_images
        set this_image to item i of the_images
        my enhance()
        save this_image in this_image
    end repeat
end tell

on enhance()
    tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
end enhance

如果这个不起作用,我道歉;我是iPhoto的新手,我正在尽我所能。 :S

EDIT2:好的,我道歉。上面的脚本不起作用(没有删除以显示其他人不应该做的事情)。这个可能不会起作用,但不管怎么试试......

tell application "iPhoto"
    set these_images to (get the selection) as list
    repeat with i from 1 to the count of these_images
        set this_image to item i of these_images
        my enhance(this_image)
        save this_image in this_image
    end repeat
end tell

on enhance(this_image)
    tell application "System Events"
        tell process "iPhoto"
            keystroke return
            --possible pseudo-code
            click menu item "Edit" of menu bar 2
            click menu item "Enhance" of menu "Quick Fixes"
            --end possible pseudo-code
        end tell
     end tell
end enhance

:S

@Downvoter:小心解释一下?