如何使用Homebrew安装Imagemagick?

235
我正在尝试在OSX Lion上安装Imagemagick,但是有些地方似乎出了问题。
-> brew install imagemagick

/usr/local/git/bin/git
==> Cloning https://github.com/adamv/ImageMagick.git
Cloning into /Users/klebershimabuku/Library/Caches/Homebrew/imagemagick--git...
fatal: https://github.com/adamv/ImageMagick.git/info/refs not found: did you run git      update-server-info on the server?
Error: Failure while executing: git clone --depth 1 https://github.com/adamv/ImageMagick.git /Users/kleber/Library/Caches/Homebrew/imagemagick--git

brew doctor说:

-> brew doctor
We couldn't detect gcc 4.0.x. Some formulae require this compiler.

Some "config" scripts were found in your path, but not in system or Homebrew folders.

`./configure` scripts often look for *-config scripts to determine if software packagesare installed, and what additional flags to use when compiling and linking.

Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew provided script of the same name.

/Users/kleber/.rvm/gems/ruby-1.9.2-p180@global/bin
passenger-config

Setting DYLD_LIBARY_PATH can break dynamic linking.
You should probably unset it.

是的,我已经安装并运行了XCode 4.1。

-> brew update
From http://github.com/mxcl/homebrew
* branch            master     -> FETCH_HEAD
Already up-to-date.

6
你需要运行 brew update 命令;我们现在使用不同的镜像源来安装 ImageMagick,而 adamv 的镜像源已经不存在了。 - Adam Vandenberg
1
我已经执行了brew update。它已经是最新的了。 - Kleber S.
2
你可能需要手动更新,我们最近遇到了一些问题:https://github.com/mxcl/homebrew/issues?labels=update-install-issue&sort=updated&direction=desc&state=open&page=1 - Adam Vandenberg
使用那里提到的脚本解决了问题。谢谢! - Kleber S.
那是什么脚本呢?该链接指向被标记为“update-install-issue”的问题,我找不到特定的强制更新脚本... 我不愿意触碰 /usr/local/.git,所以我对使用user478798(下面)的脚本持犹豫态度。 - davidhund
显示剩余3条评论
6个回答

206
您可以尝试以下命令来安装ImageMagick:brew update && brew install imagemagick

7
这在我使用的 Mac OS 10.11.1 El Capitan 上完美地运行了。 - otmezger
19
请注意,brew upgrade 会升级 homebrew 中的所有内容。 - Apie

98

对我来说最快的解决方法是执行以下操作:

cd /usr/local
git reset --hard FETCH_HEAD

然后我重试了brew install imagemagick,它从新的镜像源正确地拉取了软件包,而不是adamv。

如果这不起作用,请确保/Library/Caches/Homebrew文件夹中不包含任何imagemagick文件或文件夹。如果有,请删除它们。


1
今天这个方法已经不再适用了。如果你现在遇到了问题,那是因为你试图安装一个依赖于已废弃仓库的旧版本。 - MattiSG
3
可执行文件在哪里? - chovy
sudo chown $(whoami) /usr/local , cd /usr/local , git reset --hard FETCH_HEAD , brew install imagemagick , 今天这个对我有效。 - Nam Nguyen
5
在Mac上,可执行文件名为"magick",并且会在/usr/local/bin/magick链接到类似于/usr/local/Cellar/imagemagick/7.0.8-8/bin/magick的位置。 - Kevin Hutchinson

78
brew install imagemagick

别忘了安装 gs ,它是一个依赖项,如果您想将 PDF 转换为图像,就需要它:

brew install ghostscript

1
Ghostscript会自动安装为依赖项。 - pHoutved
1
Ghostscript会自动安装为依赖项。 - undefined

8

我在这里回答旧的帖子(有点离题),因为当我搜索如何在Mac OS上安装Image Magick以在本地web服务器上运行时,这是我找到的。仅仅使用brew install Imagemagick是不够的。您还必须安装PECL以加载PHP模块。

来自此SO答案

brew install php
brew install imagemagick
brew install pkg-config
pecl install imagick

你可能需要执行sudo apachectl restart命令。然后在运行于你的Web服务器上的简单php脚本中检查你的phpinfo()

如果还没有出现,那么你很可能在Mac上运行了多个版本的PHP(一个通过命令行,一个通过Web服务器)。解决这个问题超出了这个答案的范围,但有一些不错的选择可以尝试。


1

我遇到了类似的错误,通过在运行brew install imagemagick之前运行brew update来解决问题。


-20

你可以这样做:

brew reinstall php55-imagick

其中,php55是您的PHP版本。


8
这不是对问题的回答,但是对我很有帮助。我只是想知道PHP ImageMagick公式的名称,然后通过搜索引擎找到了这里。 - Glutexo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接