AppleScript-Droplet: convert image to monochrome / grayscale / black&white

Hello,

i am used to applescript itself and now willing to write me a small droplet which converts dropped images (jpg & png) to grayscale images.

right now i am wondering which might be the best application i could use for that ?

First ideas was ImageMagick (somehow special ...macports) or Sips.

Is there any chance that i can use a more usual application like Preview from applescript to do the convert task ?


any ideas ?

Best regards
fidel

MacBookPro 15,4" 1,83 GHz; Mac Pro 2,66 Ghz; Macbook 2,0 GHz, Mac OS X (10.5.5)

Posted on Jun 14, 2009 9:01 AM

Reply
5 replies

Jun 14, 2009 4:12 PM in response to fidel-castro

The following droplet will use Preview to convert dropped images (both jpg & png) to grayscales images:

on open droppedImages
tell application "Preview"
activate
repeat with currentImage in droppedImages
open currentImage
tell application "System Events"
keystroke "c" using {option down, command down}
tell process "Preview"
set value of value indicator 1 of slider 2 of window 1 to 0
-- other image modifications are possible here
end tell
end tell
end repeat
tell application "System Events" to tell process "Preview" to click button 1 of window 1
end tell
end open

Just a starting point.

Jun 15, 2009 2:23 AM in response to Pierre L.

Hi Piere,

that looks great - i added the applescript/keystroke part for save & quit and the result is perfect for my needs.

My mistake was to just check the offered options in automator - ignoring the keystroke possibilities.

Thanks once again

Best regards
fidel


code:
on open droppedImages
tell application "Preview"
activate
repeat with currentImage in droppedImages
open currentImage
tell application "System Events"
keystroke "c" using {option down, command down}
tell process "Preview"
set value of value indicator 1 of slider 2 of window 1 to 0
-- other image modifications are possible here
end tell
end tell
end repeat
tell application "System Events" to tell process "Preview" to click button 1 of window 1
-- save
tell application "System Events"
keystroke "s" using command down
end tell
-- quit preview
quit
end tell
end open

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AppleScript-Droplet: convert image to monochrome / grayscale / black&white

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.