Jump to content

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?
Link to comment

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.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...