1

Workflow

What I want to do is select a bunch of images with varying dimensions and uniformly apply a percentage scale to resize them. The workflow comes very close to that. But I cant get more specific to the nearest tenths. By pixels it only takes length into consideration whereas I want the width. So i figured as long as it is in applescript I can easily specify the scale I want. I intend to run the script as a service.

  • 2
    This looks like an XY Problem, so can you describe in more details which problem you are trying to solve here (without already making the assumption that AppleScript is the way to go)? Or describe in more detail why AppleScript is a must? – nohillside May 1 '16 at 7:58
1

You can use a "Run Shell Script" action and sips to downscale your pictures to any value. Add a "Run Shell Script" action, make sure the input method is set to "stdin" (should be the default) and insert the following script

SCALEFACTOR=500
while IFS= read file; do
    sips --resampleWidth $(($(sips -g pixelWidth "$file" |
                                  sed -n -e '/pixelWidth/s/.*pixelWidth: //p')
                            * $SCALEFACTOR / 1000)) "$file" --out "${file%/*}/resized-${file##*/}"
done

Shell arithmetic only supports integer values, so you'll have to specify the scale factor in thousands (e.g. 424 for 42.4%)

  • Did you test that code and if so how exactly did you test it? It doesn't do anything for me. BTW It's "Run Shell Script" action. – user3439894 May 1 '16 at 12:15
  • Sorry, forgot to take the path to the files into account. Fixed. – nohillside May 1 '16 at 12:54
  • Works for me now. +1 I have to admit I didn't even try to debug it, and I should have. :) – user3439894 May 1 '16 at 13:20
  • You probably want to delete the lonesome image file which got created in your home folder :-) – nohillside May 1 '16 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .