Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error for convert command in command line

Tags:

bash

shell

macos

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.

like image 230
Nevin Raj Victor Avatar asked Feb 20 '15 11:02

Nevin Raj Victor


People also ask

What does convert command do?

In computing, convert is a command-line utility included in the Windows NT operating system line. It is used to convert volumes using the FAT file systems to NTFS.

What does the Convert command do in DOS?

The convert command is used to change FAT volumes to NTFS.

How install convert in Linux?

convert is part of the package ImageMagick; try sudo yum install ImageMagick (or other privilege escalation method as appropriate to your system). Show activity on this post. Next time you need a command like this you can figure out what package to install by running something like yum whatprovides '*/convert' .


2 Answers

You can also make it with help of Homebrew - which is quite nice and popular package manager

  1. To Install homeBrew past in your terminal

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. To install imagemagick past in the terminal

    brew install imagemagick

like image 126
Nikolay Shubenkov Avatar answered Oct 02 '22 14:10

Nikolay Shubenkov


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.
like image 38
Anshad Rasheed Avatar answered Oct 02 '22 14:10

Anshad Rasheed