Anonymous Anonymous - 1 year ago 110
Bash Question

Error for convert command in command line

I have a bash shell script as below.

#!/bin/bash

SIZES=("512" "1024" "2048")

for i in ${!SIZES[*]}
do
SIZE=${SIZES[$i]}
echo $SIZE

# first, resize original image
convert -resize $SIZE"x"$SIZE! chernarus2048.jpg chernarus$SIZE"x"$SIZE.jpg
mkdir tiles$SIZE
# slice resized image into 256x256 tiles
convert -crop 256x256 chernarus$SIZE"x"$SIZE.jpg tiles$SIZE/tile%04d.jpg
rm chernarus$SIZE"x"$SIZE.jpg
done


But When I run this in command line using the following command

sh generate_tiles.sh chernarus2048.jpg


I am getting an error convert: command not found

I am using OS X Yosemite 10.10.2.The image is kept in the same folder where the shell script is placed.Please help me out.

Answer

First you have to install macport from https://www.macports.org/install.php Then install imagemagick using $ sudo port install ImageMagick or http://cactuslab.com/imagemagick/ Then close your terminal and restart the pc and run your code again.