Get iPhoto to Enhance thousands of photographs?
I've discovered that thousands of the photos in my iPhoto library do not have proper icons. I've tried rebuilding the database and that hasn't worked. However, one technique that does work is simply clicking the "edit" and then the Enhance button.
I've discovered that if I edit the first photo in a series I can fix them all by toggling back and fort开发者_开发知识库h between the "Enhance" button and the right-arrow button.
Is there any way to automate this?
I haven't used iPhoto that much, but I have used applescript for quite some time. I'm guessing the Enhance
button is located under the Edit
menu. If that's true, then you can...
tell application "System Events" to tell process "iPhoto" to click menu item "Enhance" of menu "Edit" of menu bar 1
You said you have thousands of photos that need enhancing. AppleScript is perfect for doing things just like this. To automate it entirely (load the images as well as enhance them), you would use a droplet, as shown here:
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
EDIT: The above code won't work (I haven't deleted it to show what others shouldn't do), but this one should...
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
I apologize if this one doesn't work either; I'm completely new to iPhoto and I'm doing my best. :S
EDIT2: OK, I apologize. The above script doesn't work (haven't deleted to show what others shouldn't do). This one probably won't work, but give it a try anyways...
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: Care to explain?
精彩评论