Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making an Automator workflow that uses the shell script action to process a selection of images with the imagemagick composite command. Only I'm having issues getting it going. According to the results I get when I run the workflow, everything is working however, I know it's not due to the fact that the changes I'd expect to see in the folder of images are not present. I know that the imagemagick command I'm using is correct as it works correctly from the console. (I echoed the composite command to the output & copied it into a Terminal session. Ran like a charm). BTW: The workflow's for processing a fade in on a stop motion movie I made. Yes I know I could use video tools to achieve the same thing, but the ones I have access to screw up the image quality on output.

Here's the script

rate=$(echo "scale=2; 100/$imagesCount"|bc)
for f in "$@"; do
    composite -blend "$percentage" -size 1280x720 "$f" xc:black -alpha Set "$fileName-1.jpg"
    percentage=$(echo "scale=2; $percentage+$rate"|bc)

At first I thought at the cause of the problem might be spaces in the paths, but I removed this possibility by shifting the files to a path without spaces, but that had no effect.

I'm almost certain the issue is related to something in the bash command but I don't know bash at all, this is my first time writing any bash command scripts, but I am very knowledgeable in Windows console scripting and would have no trouble getting this to work there.

If the error in the script isn't obvious enough to catch, would someone propose a method to debug this so I can figure out why the images are not getting processed even though the script runs without error?

share|improve this question
Maybe it's a PATH issue. Does it work when you replace composite with its absolute path (can be determined by executing which composite on the Terminal)? – Percival Ulysses Sep 8 '13 at 17:15
The following line of code seems to be missing a quotation mark: percentage=$(scale=2; $percentage+$rate"|bc) – Kaydell Sep 8 '13 at 19:08
Thanks for pointing that out Kaydell. It was also missing its echo. – Greg Sep 8 '13 at 22:44
Composite's installed correctly. i used Cactus Labs ImageMagick installer which installs ImageMagick and adds it to the path. Very handy. – Greg Sep 8 '13 at 23:25
Did it work to change $f to f or was that just a transcription error? Also your capitalization on fileName is inconsistent. – beroe Sep 9 '13 at 16:34

I would just do the whole thing at the command line as a shell script instead of using Automator to launch it. Put #!/bin/bash as the first line, and run it as image*.png

where image*.png is your set of image files that you are apparently selecting in Automator?

If you need to run it on all files in a folder, that can be done too.

You can also test your script in automator using echo ${f%.*} instead of the commands themselves.

share|improve this answer

Replace for $f with for f. for $f in aa; do :; done results in an error like `$f': not a valid identifier.

Also if composite is not on the path, specify the full path to it (like /usr/local/bin/composite).

share|improve this answer
Thanks for the hint. I'll go check my typing. – Greg Sep 8 '13 at 22:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.