Получить iPhoto, чтобы улучшить тысячи фотографий? - PullRequest
1 голос
/ 30 апреля 2011

Я обнаружил, что тысячи фотографий в моей библиотеке iPhoto не имеют соответствующих значков.Я пытался восстановить базу данных, и это не сработало.Тем не менее, одна из техник, которая работает, - это просто нажать кнопку «Редактировать», а затем кнопку «Улучшить».

Я обнаружил, что если я редактирую первую фотографию в серии, я могу исправить их все, переключая их назад и вперед.между кнопкой «Улучшение» и кнопкой со стрелкой вправо.

Есть ли способ автоматизировать это?

1 Ответ

1 голос
/ 23 июля 2011

Я не очень часто использовал iPhoto, но у меня уже есть , который использовал applecript уже довольно давно.Я предполагаю, что кнопка Enhance находится в меню Edit.Если это правда, тогда вы можете ...

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

Вы сказали, что у вас есть тысячи фотографий, которые нуждаются в улучшении.AppleScript идеально подходит для таких вещей.Чтобы полностью автоматизировать его (загружать изображения и улучшать их), вы должны использовать каплю, как показано здесь:

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: Хотите объяснить?

...