Jump to content
sebastianf

How to resize selected Images with an Apple script

Recommended Posts

Hi,

 

I want to create a workflow to resize my selected Images.

first I created a File Action and the a Run NSAppleScript with the following text

 

 

on open (_files)
    tell application "Image Events" to launch
    
    repeat with _file in _files
        try
            tell application "Image Events"
                set _image to open _file
                
                scale _image by factor 0.5
                save _image in _file
                close _image
            end tell
        end try
    end repeat
end open
 
It dow not work :(
 
Can somebody help me please?

Share this post


Link to post

Hi,

 

I want to create a workflow to resize my selected Images.

first I created a File Action and the a Run NSAppleScript with the following text

 

 

on open (_files)
    tell application "Image Events" to launch
    
    repeat with _file in _files
        try
            tell application "Image Events"
                set _image to open _file
                
                scale _image by factor 0.5
                save _image in _file
                close _image
            end tell
        end try
    end repeat
end open
 
It dow not work :(
 
Can somebody help me please?

 

When using the Run NSApplescript module, you should wrap your code in "on alfred_script(q)" and end with "end alfred_script". This is how you pass the selected files into the script, using the variable q. Obviously, that variable name could be changed to be whatever you want. If you chose a Run Script module instead and set the languages to /usr/bin/osascript then you wouldn't have to wrap the code. Then the files would be passed via the {query} variable.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...