如何在Ubuntu上安裝ImageMagick


使用ImageMagick建立、編輯、組合或轉換點陣圖畫素。它實際上可以讀取和寫入多種編解碼器(超過200種)的快照,包括PNG、JPEG、JPEG-2000、GIF、TIFF、DPX、EXR、WebP、Postscript、PDF和SVG。使用ImageMagick調整大小、翻轉、映象、旋轉、扭曲、剪下和開發快照,更改影像顏色,應用各種特效,或繪製文字、線條、多邊形、橢圓和貝塞爾曲線。本文介紹了“如何在Ubuntu上安裝ImageMagick”。

在安裝ImageMagick之前,需要構建必要的元件,如下所示:

$sudo apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y

示例輸出如下:

Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
The following NEW packages will be installed:
   checkinstall
0 upgraded, 1 newly installed, 0 to remove and 204 not upgraded.
Need to get 121 kB of archives.
After this operation, 516 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 checkinstall amd64 1.6.2-4ubuntu1 [121 kB]
Fetched 121 kB in 0s (162 kB/s)
..................................................................................

現在下載ImageMagick,如下所示:

$sudo wget http://www.imagemagick.org/download/ImageMagick.tar.gz

示例輸出如下:

--2017-01-27 11:49:08-- http://www.imagemagick.org/download/ImageMagick.tar.gz
Resolving www.imagemagick.org (www.imagemagick.org)... 198.72.81.86
Connecting to www.imagemagick.org (www.imagemagick.org)|198.72.81.86|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12746042 (12M) [application/x-gzip]
Saving to: ‘ImageMagick.tar.gz’

ImageMagick.tar.gz 100%[===================>] 12.16M 1.28MB/s in 14s

2017-01-27 11:49:22 (907 KB/s) - ‘ImageMagick.tar.gz’ saved [12746042/12746042]

解壓下載的檔案,如下所示:

$sudo tar xzvf ImageMagick.tar.gz

示例輸出如下:

ImageMagick-7.0.4-5/PerlMagick/t/ttf/
ImageMagick-7.0.4-5/PerlMagick/t/ttf/read.t
ImageMagick-7.0.4-5/PerlMagick/t/ttf/input.ttf
ImageMagick-7.0.4-5/PerlMagick/t/composite.t
ImageMagick-7.0.4-5/PerlMagick/t/input.dib
ImageMagick-7.0.4-5/PerlMagick/t/input_p5.pgm
ImageMagick-7.0.4-5/PerlMagick/t/input_70x46.uyvy
ImageMagick-7.0.4-5/PerlMagick/t/input.im8
ImageMagick-7.0.4-5/PerlMagick/t/input.sgi
ImageMagick-7.0.4-5/PerlMagick/t/png/
ImageMagick-7.0.4-5/PerlMagick/t/png/input.mng
ImageMagick-7.0.4-5/PerlMagick/t/png/write.t
ImageMagick-7.0.4-5/PerlMagick/t/png/read-16.t
ImageMagick-7.0.4-5/PerlMagick/t/png/input_256.png
ImageMagick-7.0.4-5/PerlMagick/t/png/input_bw.png
ImageMagick-7.0.4-5/PerlMagick/t/png/input_truecolor.png
ImageMagick-7.0.4-5/PerlMagick/t/png/write-16.t
ImageMagick-7.0.4-5/PerlMagick/t/png/input_mono.png
..........................................................................

要驗證上述命令,請使用以下命令:

$ ls

示例輸出如下:

ImageMagick-7.0.4-5 ImageMagick.tar.gz

現在進入解壓後的目錄,如下所示:

$cd ImageMagick-7.0.4-5

要檢查配置,請使用以下命令:

~/ImageMagick-7.0.4-5# ./configure

要構建原始碼,請使用以下命令:

~/ImageMagick-7.0.4-5# make clean
~/ImageMagick-7.0.4-5# make
~/ImageMagick-7.0.4-5# checkinstall
~/ImageMagick-7.0.4-5# ldconfig /usr/local/lib

要獲取更多關於Magick的資訊,請使用以下命令:

$ magick -help

示例輸出如下:

Usage: magick [ {option} | {image} ... ] {output_image}
       magick [ {option} | {image} ... ] -script {filename} [ {script_args} ...]
       magick -help | -version | -usage | -list {option}

要獲取Magick的版本,請使用以下命令:

$ magick -version

示例輸出如下:

Version: ImageMagick 7.0.4-5 Q16 x86_64 2017-01-27 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): x zlib

在這篇文章中,我們學習瞭如何在Ubuntu上安裝ImageMagick,我們將繼續提供更多基於Linux的技巧和提示。繼續關注!

更新於:2020年1月23日

569 次瀏覽

開啟你的職業生涯

完成課程獲得認證

開始學習
廣告