GraphicsMagickインストール

MavericksOS X 10.9.2)へインストールしたときのメモです。

homebrewでGraphicsMagickインストール

コマンドリファレンスはGraphicsMagick GM Utility
homebrewでのインストールオプションはhttps://github.com/Homebrew/homebrew/blob/master/Library/Formula/graphicsmagick.rbなどで確認できます。

$ brew install graphicsmagick
==> Installing graphicsmagick dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.
######################################################################## 100.0%
==> Pouring libpng-1.5.18.mavericks.bottle.tar.gz
🍺  /usr/local/Cellar/libpng/1.5.18: 15 files, 1.0M
==> Installing graphicsmagick
==> Downloading https://downloads.sourceforge.net/project/graphicsmagick/graphic
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/graphicsmagick/1.3.19 --enable-shared
==> make install
🍺  /usr/local/Cellar/graphicsmagick/1.3.19: 465 files, 12M, built in 66 seconds

Graphicsmagick gemインストール

ドキュメントはFile: README — Documentation for graphicsmagick (1.0.6)
ただし大半がmethod_missingしたり委譲したりしてるのでドキュメント読んで役立つか分からんです。

$ gem install graphicsmagick
Fetching: subexec-0.2.3.gem (100%)
Fetching: graphicsmagick-1.0.4.gem (100%)
Successfully installed subexec-0.2.3
Successfully installed graphicsmagick-1.0.4
2 gems installed

gem dependencyおかしいやん

$ gem dependency graphicsmagick
Gem graphicsmagick-1.0.4
  subexec (>= 0)

なのに動かない。

$ pry
[1] pry(main)> require 'graphicsmagick'
LoadError: cannot load such file -- active_support/core_ext/numeric/time
from /Users/riocampos/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

https://github.com/dignoe/graphicsmagick/blob/master/lib/graphicsmagick/image.rb
を確認すると

require 'tempfile'
require 'subexec'
require 'shellwords'
require 'graphicsmagick/utilities'
require 'active_support/core_ext/numeric/time'
(以下略)

…Active Support入れてないとあかんやん。
なのに
https://github.com/dignoe/graphicsmagick/blob/master/Gemfile

source 'https://rubygems.org'

# Specify your gem's dependencies in graphicsmagick.gemspec
gemspec

と全く書いていない。
実はRuby on Railsを使っていないので、まだインストールしていませんでした。
仕方ないので入れてみました(別エントリに書きます)。
Ruby on Railsを入れたら

$ pry 
[1] pry(main)> require 'graphicsmagick'
=> true

と使えるようになりました。
# Ruby使う人はおそらく全員がRails入れてる、と思ってるんですねw