How to make Mac Application (use Automator) which convert image file of PDF to eps file with ImageMagick

788 views Asked by At

I want to automate convert image file of PDF to eps file with ImageMagick. And I would like to be able to do this with drag and drop. So, I'd like to create an .app file using Automator.

I tried following things.

  1. Start "Automator.app", and Choose "Application" type for the document.
  2. Drag and drop "Run Shell Script" into workflow area.
  3. Setting the Shell is "/bin/bash", and the pass input is "as arguments".
  4. Write the scripts below.

     for f in "$@"     
     do
         fname="${f%.*}" 
         convert $f $fname.eps
     done
    

When drag and drop an image file into .app file, the following error code will be displayed.

The action "Run Shell Script" encounted an error.

How to fix it?

--

macOS Sierra(10.12)

1

There are 1 answers

0
emcconville On BEST ANSWER

Ensure that your environment PATH includes the location of convert. I would also suggest moving the file extension to fname assignment, and quote the path names (in the event of unicode file names).

PATH=$PATH:/usr/local/bin
for f in "$@"     
do
   fname="${f%.*}.eps" 
   convert "$f" "$fname"
done

Tips

  • In Terminal.app run which convert to find the correct path to your convert binary.
  • During development, redirect convert stderr to a log file so you can evaluate the error.

    convert "%f" "$fname" 2> /tmp/my_app.log