Make sure you have have MacPorts installed. Run the command to update your port command and ports available.
sudo port selfupdate
sudo port sync
Note: Run port version. As of this writing, the latest version is 1.600.
Let’s get ImageMagick using port intall.
sudo port install ImageMagick
When it’s done, run port installed and make sure you find ImageMagick. Next, we install Rmagick via gem. Run the command below:
sudo gem install rmagick
Note: It’s rmagick not Rmagick. sudo gem install Rmagick will result in ERROR: could not find Rmagick locally or in a repository.
When it’s done, check if rmagick is installed properly by running gem list. Now we are going to test if rmagick works properly. Create a file called test_rmagick.rb, and copy and paste the code below.
#!/usr/bin/env ruby -wKU
# Test if rmagick is working properly or not.
# When run, this file creates a image file 'path.gif' in the same directory.
# the sample code is from http://rmagick.rubyforge.org/portfolio3.html
require 'rubygems'
require 'rmagick' # Don't use a capital 'R'.
canvas = Magick::Image.new(240, 300,
Magick::HatchFill.new('white','lightcyan2'))
gc = Magick::Draw.new
gc.fill('red')
gc.stroke('blue')
gc.stroke_width(2)
gc.path('M120,150 h-75 a75,75 0 1, 0 75,-75 z')
gc.fill('yellow')
gc.path('M108.5,138.5 v-75 a75,75 0 0,0 -75,75 z')
gc.draw(canvas)
canvas.write('path.gif')
If you find an image file titled “path.gif” after running the script, your installation is successful.