Anonymous Anonymous - 1 year ago 149
Bash Question

Error for convert command in command line

I have a bash shell script as below.


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

for i in ${!SIZES[*]}
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

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

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.


First you have to install macport from Then install imagemagick using $ sudo port install ImageMagick or Then close your terminal and restart the pc and run your code again.