Search code examples
macosimagemagickautomator

imagemagick and automator DPI change


I am trying to create a workflow in automator to change DPI from 72 to 300, so that I can use it on any image in Finder (when i right click on the image, then I can run the action).

When I run the command in terminal, it works fine:

mogrify -units PixelsPerInch *.jpg  -density 300 *.jpg

However, when I use it in shell script, it does not work, and I can't figure out why. This is what I have so far:

for f in "$@"
do
       /opt/ImageMagick/bin/mogrify mogrify -units PixelsPerInch *.jpg  -density 300 *.jpg
done

Screenshot from Automator

Any help will be highly appreciated.


Solution

  • mogrify is for batch conversion (thus your *.jpgin the working version) but in your example, you have created a loop to step through files. You don't seem to be using your f variable at all. You should get the command to work on individual files using the convert command instead of mogrify and then plug in$fwherever the filename would occur.