在Mac下安裝GraphicsMagick

來源:互聯網
上載者:User


GraphicsMagic 有一個Nodejs的用戶端:https://github.com/aheckmann/gm簡直就是nodejs處理圖片的神器呀!但是使用它之前必須得安裝GraphicsMagic,於是開始了痛苦的折騰之旅.開源系統或者組件就是這樣,編譯安裝一個東西,同時又依賴別的組件,又要編譯、安裝... 真的很蛋疼...GraphicsMagic根據使用功能的不同,依賴不同的組件,我需要的只是對jpeg和png進行簡單的圖片處理(縮放、裁剪啊什麼的,不過它的功能可以更加強大),主要依賴了兩個組件:
  www.2cto.com  libjpeg-6b.tar.gz    ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/delegates/libjpeg-6b.tar.gzlibpng-1.4.7.tar.gz    http://sourceforge.net/projects/libpng/files/libpng14/1.4.7/libpng-1.4.7.tar.gz/download
 首先必須先下載以上的兩個組件,然後解壓,然後./confiure 然後sudo make&make install接著就可以安裝GraphicsMagic了:到這裡 
http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick-binaries/ 選擇你需要的版本並下載。然後解壓。在解壓的目錄裡運行:./configure CC=clangmakesudo make install 注意confiure命令後面的CC=clang。它指定了編譯器為Mac下推薦使用的clang。如果沒有這個參數,Makefile將會使用系統預設的編譯器進行編譯,而這個編譯器不是GraphicsMagic所推薦的,並且在make的過程中會出現以下錯誤:Undefined symbols for architecture x86_64:  "___builtin_object_size", referenced from:      _BlurImageScanlines.omp_fn.6 in libGraphicsMagick.a(magick_libGraphicsMagick_la-effect.o)      _XShearImage.omp_fn.0 in libGraphicsMagick.a(magick_libGraphicsMagick_la-shear.o)      _YShearImage.omp_fn.1 in libGraphicsMagick.a(magick_libGraphicsMagick_la-shear.o)ld: symbol(s) not found for architecture x86_64collect2: ld returned 1 exit statusmake[1]: *** [utilities/gm] Error 1make: *** [all] Error 2  www.2cto.com  切記要在confiure的時候./configure CC=clang 呀,這個是哥血淚摸索出來的經驗,希望奉獻出來讓大家少走彎路。好,npm install gm然後寫一段nodejs的代碼測試一下:var gm = require('gm');gm('./test.jpg').size(function(err, image){    console.log(image.width, image.height);}); 好了,好好享受生活吧~ 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.