Linux下安裝 ImageMagick 和 imagick教程

來源:互聯網
上載者:User

ImageMagick 安裝

wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.8.9-7
./configure --prefix=/usr/local/ImageMagick/ --enable-lzw --with-modules --with-quantum-depth=8?--enable-shared --disable-openmp
make && make install

編譯安裝過程時間比較長,請耐心等待!

安裝完成後執行:/usr/local/ImageMagick/bin/convert logo: logo.gif 測試一下 ImageMagick 是否可以正常運行,如果沒有提示任何錯誤,然後檢查執行命令時所在的目錄,看看是否產生了logo.gif 這個檔案。

也可以在安裝完成後,運行convert -version命令檢測,應該會出現類似下面內容的資訊:


<p>Version: ImageMagick 6.8.9-7 Q8 x86_64 2014-08-20 http://www.imagemagick.org<br>
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC</p>

convert預設安裝到了/usr/local/ImageMagick/bin下面,上面的命令可能提示找不到convert命令,那麼可以在/usr/bin下面建立一個到/usr/local/ImageMagick/bin/convert的連結:

cd /usr/bin
ln -s /usr/local/ImageMagick/bin/convert convert

ImageMagick安裝說明

1、在安裝時也可以加入–without-xxx來禁止一些選項,具體的就 ./configure –help | grep without來查看有哪些吧;

2、關於Q8,Q16,Q32的說明:

3、–enable-shared 編譯成共用庫;
4、–disable-openmp 禁用多線程,使用多線程效能並沒有提高,但CPU佔用達到了100%,所以禁用;

5、卸載命令:make uninstall。

PHP擴充imagick安裝

wget http://pecl.php.net/get/imagick-3.1.2.tgz
tar zxvf imagick-3.1.2.tgz
cd imagick-3.1.2
phpize  //每個伺服器位置不一樣
./configure --with-php-config=/你的php路徑/php-config --with-imagick=/usr/local/ImageMagick/
make && make install

imagick安裝執行結果

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files:          /usr/local/php/include/php/
產生imagick.so到/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/,然後手動設定php.ini使其生效,手工在php.ini裡面添加上imagick擴充,extension=imagick.so,重啟php,檢查phpinfo,看是否載入成功,該擴充不是使用–with-imagick在編譯PHP的時候靜態編譯進PHP,而是類似memcache的方式,編譯成so模組動態載入的。

imagick無法安裝時的解決辦法

有時安裝imagick是會提示:

“configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.”

這是因為只安裝了“ImageMagick”而沒有安裝“ImageMagick-devel”,通過下面的命令列安裝ImageMagick-devel,然後重新按上面的步驟安裝imagick就好了。

yum install ImageMagick-devel

Discuz!X上的ImageMagick設定

登入Discuz!X後台,在“上傳設定”裡選擇ImageMagick,並在ImageMagick程式安裝路徑寫上:/usr/local/ImageMagick/bin/

關閉多線程

單線程轉換每張圖片大概50ms,兩個線程卻需要500ms?

用convert –version命令查看,看是否出現openMP字樣,出現的話,是因為機器不支援openMP導致的,需要重新編譯./configure –disable-openmp,再進行安裝。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.