Issue
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'm getting an error convert: command not found
I'm 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.
Solution
Steps to follow
- Confirm macport is installed for reference https://www.macports.org/install.php
- Then install imagemagick using any of the following method
install using command$ sudo port install ImageMagick
or using Homebrew command brew install imagemagick
or download from the link http://cactuslab.com/imagemagick/
- Then close your terminal and restart the pc and run your code again.
Answered By - Anshad Rasheed Answer Checked By - Willingham (WPSolving Volunteer)