Error for convert command in command line - 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.

You can also make it with help of Homebrew - which is quite nice and popular package manager
To Install homeBrew past in your terminal
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install imagemagick past in the terminal
brew install imagemagick

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.

convert is part of ImageMagick which is not installed by default on OS X.
From the download instructions on the ImageMagick site:
Install MacPorts
Install ImageMagick with
$ sudo port install ImageMagick

port install not work for me.
it always return "Error: Port ImageMagick not found"
if you failed installing with port, you can download pkg and install it directly from http://cactuslab.com/imagemagick/

Related

How to use ImageMagick with XQuartz

I am trying to create animated visualization in R and people say needs to install ImageMagick. However, it seems that current Mac no longer support x11, while ImageMagick just needs X11 server on Mac. Install ImageMagick
I have also tried brew install imagemagick --with-x11, doesn't work and only returned so many errors.
Apples says need to use XQuartz to replace x11. I have XQuartz, but when I turned on it, typed the same commands here, still give me the same error
display: delegate library support not built-in '' (X11) # error/display.c/DisplayImageCommand/1891.
So, my questions is, how to install and use ImageMagick with Mac XQuartz?
I created a Homebrew ImageMagick X11 formula that can be used like this:
brew uninstall imagemagick # without X11 support
brew install --cask xquartz
brew install tlk/imagemagick-x11/imagemagick
Note that homebrew-core used to support formula options such as --with-x11 in order to enable a configure option of the same name. This is no longer the case as the Homebrew maintainer(s) decided to remove formula options from homebrew-core formulas.
Updated Answer
Note that things have changed a bit since I wrote this answer, Homebrew no longer supports installation options such as --with-x11. One possibility, pointed out in the comments by #MattWhite was to install ImageMagick interactively:
brew install imagemagick -i;
./configure --disable-osx-universal-binary --prefix=/usr/local/Cellar/imagemagick/7.0.8-66 --disable-silent-rules --with-x11
make install
exit
Another option that occurred to me was that, rather than installing all of XQuartz, you could just add your own delegate that uses macOS's built-in Preview app and tell ImageMagick to use that, i.e. delegate to it. This means you can do things like:
magick SomeImage.png -crop 100x100+10+10 display:
For this to work, you need to find your delegates.xml file. I used this:
magick -list delegate | awk '/^Path/ {print $2}'
and mine is at:
/opt/homebrew/Cellar/imagemagick/7.1.0-16/etc/ImageMagick-7/delegates.xml
Then I edited that file and added a line very close to the end, but just above the last line like this:
<delegate decode="miff" encode="display" spawn="True" command="magick %i %u.png ; /usr/bin/open -a Preview %u.png"/>
That converts any file formats that ImageMagick knows into a PNG which the Preview app understands and should be able to represent most images, even those with 16-bit depth and transparency.
Original Answer
In general, to use ImageMagick with X11, you will probably be most likely to succeed if you follow the following steps:
Step 1 - Install or update Xcode command line tools
It is important that your developer tools are up-to-date, especially if you have updated your macOS version since setting them up originally. You can do this with:
xcode-select --install
Step 2 - Ensure ImageMagick is correctly installed
The easiest way to do this is first to ensure that old versions of ImageMagick are removed and cleaned up and that you then install (or re-install) with the latest version:
brew update # update homebrew itself
brew rm imagemagick # remove old IM versions
brew install imagemagick --with-x11 # install latest IM version including X11 support
Step 3 - Check
If you have been trying for ages to install ImageMagick, you may have left some old versions lying around. It is important that you use the homebrew-installed version in /usr/local/bin, so check you are running the version you expect with the following:
which convert # should report "/usr/local/bin/convert"
which magick # should report "/usr/local/bin/magick"
identify -version # should report same version as next command
brew info imagemagick
Step 4 - Start X11
Start X11, it is probably easiest to fire up xclock, which not only starts X11, but also checks everything X11 is running and your X11 environment is configured correctly:
xclock &
Step 5 - Run ImageMagick X11
Now you can test your ImageMagick configuration, without needing any test images as follows - since the wizard: image is built-in:
display wizard:

Brew install class-dump doesn't work. How to fix it?

My mac is having MacOS 10.12.4 (Sierra). And I have installed homebrew using command line. This is what look like when I run "brew config" command.
Then I wanted to install class-dump using following command.
"brew install class-dump". But when it gives me following error. Can some one tell me the reason and what should I do?
I was able to solve the problem by installing class-dump manually without using home brew. I downloaded the class-dump in using this link. Then copy the class-dump file to the following location "/usr/local/bin". Then all works fine
Here is a one liner for the lazy people if you already have wget:
$ wget -qO- http://stevenygard.com/download/class-dump-3.5.tar.gz | tar xvz - -C /usr/local/bin

unicharset_extractor: command not found

I want create new train data using tesseract. So follow step which mentioned in below website.
https://blog.cedric.ws/how-to-train-tesseract-301
I got below error while i execute Unicharset in OS X terminal.
Command:
unicharset_extractor eng.micrtest.exp.box
Error:
-bash: unicharset_extractor: command not found
I have using below software versions
OS: OSX EI caption 10.11.1
tesseract 3.04.01
leptonica-1.72
libjpeg 8d : libpng 1.6.21 : libtiff 4.0.6 : lib 1.2.5
is this possible to execute unchaste_extractor command in OSx?
Thanks in advance.
Problem is "Unicharset_extractor" not install in your system. So please install tesseract training tools
INSTALL TRAINING TOOL
brew install --with-training-tools tesseract
Please uninstall tesseract if you already installed it.
UNINSTALL TESSERACT
brew uninstall tesseract
NOTE: please read logs while install training tools and follow the steps which mentioned in logs.
It’ll take some more time to install the training tool so you’ll never quiet the terminal meantime.
Please install Homebrew before work out above command.
You will need to build Tesseract training executables; they are separate from the regular Tesseract executable.
https://github.com/tesseract-ocr/tesseract/wiki/Compiling

Dark Thumbnails on EC2 with ImageMagick / RMagick

With the yum installed version of ImageMagick on the default Amazon EC2 instance I was getting dark thumbnails via rmagick.
How do I get a newer version of ImageMagick on EC2?
Using a combination of the ImageMagick source installation instructions and some instructions from a blog, I got the following to work:
Get rid of the old version
yum remove ImageMagick
Install the dependencies
You will need the appropriate ImageMagick dependencies for whatever graphic types you expect to convert.
yum install wget tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
curl and extract the ImageMagick source
cd ~/
curl -O http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
Test configuration
cd ImageMagick-xxx
./configure
Confirm configuration
There should be a yes next to all the image types you anticipate needing to convert, if not see the dependencies step above.
Build and install
make
make install

Installing meld on OS X

After I got MacPorts installed and did a 'sudo port -v selfupdate', I try to install meld.
The installation just starts to Fetching all kinds of stuff
gnome-comoon
perl5.8
perl5
pkgconfig
.....
this goes on and on.
Is that normal?
You may want to install it via HomeBrew (already mentioned before):
brew install homebrew/gui/meld
Though you may face stability issues (as I did). So I'd rather recommend to use "Meld for OSX":
Go to https://yousseb.github.io/meld/
Download DMG file you prefer (e.g. "Download latest DMG" https://github.com/yousseb/meld/releases/download/osx-6/meldmerge.dmg)
Install it to your Applications folder
We are basically done, but it is not accessible via command line.
Solution:
Write a small wrapper to run from Terminal:
echo -e '#!/bin/sh
params="$#"
open -W -a Meld --args $params' | sudo tee /usr/local/bin/meld
sudo chmod +x /usr/local/bin/meld
Try (you must use absolute paths though):
meld /home/a.txt /home/b.txt
Or just run Meld from menu.
meld is now available in homebrew. The formula can be found here.
See this answer by cmedeiros on SuperUser for more information on installing and getting it to work. This is much easier than using MacPorts.
Current command with updated formula to install meld with homebrew is:
brew install caskroom/cask/meld
Yes, it is normal to pull in dependencies but it shouldn't take too long. For comparison, installing Meld with Homebrew took about 15 minutes for me.
For reference, my installation of Meld on OS X Mavericks:
Install Xcode from the app store
Install XQuartz from package (Meld will complain if you don't have it)
command line: 'brew install meld'
If you are prompted to install the Xcode command line tools at some point, do so.
Hope this helps.
Unfortunately, the is very normal with MacPorts, and is the reason that people many have switched to homebrew http://github.com/mxcl/homebrew
However, I found this post because homebrew doesn't include Meld. Sigh.
Consider downloading macOS meld version dmg https://github.com/yousseb/meld/releases/
Brew now works brew install --cask meld.
See https://formulae.brew.sh/cask/meld#default
UPDATE Jul-23-2020
Just do :
brew install homebrew/gui/meld
using the updated brew link: brew install caskroom/cask/meld
even after this its not working when I install backup and restore tool by google. I guess its messing up with the python version.

Resources