1.查询是否已有安装
[root@li96-10 ~]# rpm -qa | grep -i ImageMagick
或者
[root@li96-10 ~]# yum list installed |grep ImageMagikc*
#我的机器上没有安装ImageMagic,如果存在就删除掉
[root@li96-10 ~]# yum remove ImageMagick
2.安装必要的库
[root@li96-10 ~]# yum install -y glib glib2 zlib-devel libpng libjpeg libtiff ghostscript freetype-devel libjpeg-devel libpng-devel libtiff-devel
3,安装ImageMagic
[root@li96-10 ~]# wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.5.8-8.tar.gz
[root@li96-10 ~]# tar zxvf ImageMagick-6.5.8-8.tar.gz
[root@li96-10 ~]# cd ImageMagick-6.5.8-8
[root@li96-10 ImageMagick-6.5.8-8]# ./configure --prefix=/usr/local/system/ImageMagick
下面是configure后的配置设置:
ImageMagick is configured as follows. Please verify that this configuration
matches your expectations.
Host system type: i686-pc-linux-gnu
Build system type: i686-pc-linux-gnu
Option Value
++++++++++++++++++++++++++++++++++++
Shared libraries --enable-shared=yes yes
Static libraries --enable-static=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=yes yes
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=no no
Delegate Configuration:
BZLIB --with-bzlib=yes yes
Autotrace --with-autotrace=no no
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=yes no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=no no
FreeType --with-freetype=yes yes
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (8.15.2)
Ghostscript fonts --with-gs-font-dir=default /usr/share/fonts/default/Type1/
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=yes no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes yes
JPEG-2000 --with-jp2=yes no
LCMS --with-lcms=yes no
LQR --with-lqr=yes no
Magick++ --with-magick-plus-plus=yes yes
OpenEXR --with-openexr=yes no
PERL --with-perl=no no
PNG --with-png=yes yes
RSVG --with-rsvg=no no
TIFF --with-tiff=yes yes
Windows fonts --with-windows-font-dir= none
WMF --with-wmf=no no
X11 --with-x= no
XML --with-xml=no no
ZLIB --with-zlib=yes yes
X11 Configuration:
X_CFLAGS =
X_PRE_LIBS =
X_LIBS =
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /usr/local/system/ImageMagick
EXEC-PREFIX = /usr/local/system/ImageMagick
VERSION = 6.5.8
CC = gcc -std=gnu99
CFLAGS = -fopenmp -g -O2 -Wall -W -pthread
CPPFLAGS = -I/usr/local/system/ImageMagick/include/ImageMagick
PCFLAGS = -fopenmp
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
MAGICK_LDFLAGS = -L/usr/local/system/ImageMagick/lib
LIBS = -lMagickCore -ltiff -lfreetype -ljpeg -lpng -lbz2 -lz -lm -lgomp -lpthread
CXX = g++
CXXFLAGS = -g -O2 -Wall -W -pthread
紧接着:
[root@li96-10 ImageMagick-6.5.8-8]# make
[root@li96-10 ImageMagick-6.5.8-8]# make install
4,配置环境变量
[root@li96-10 ImageMagick-6.5.8-8]# vi /etc/profile #把下面三行加入文件最后
export IMAGEMAGICK_HOME=/usr/local/system/ImageMagick
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/system/lib:$IMAGEMAGICK_HOME/lib
export PATH=$IMAGEMAGICK_HOME/bin:$JAVA_HOME:$PATH:$ANT_HOME/bin
[root@li96-10 ImageMagick-6.5.8-8]# source /etc/profile
5,配置动态链接库
[root@li96-10 ImageMagick-6.5.8-8]# vi /etc/ld.so.conf.d/ImageMagic.conf #加入
/usr/local/system/ImageMagic/lib
[root@li96-10 ImageMagick-6.5.8-8]# ldconfig #使其生效
[root@li96-10 ImageMagick-6.5.8-8]# identify -list format #输出下面的结果
Format Mode Description
++++++++++++++++++++++++++++++++++++++++++
3FR r-- Hasselblad CFV/H3D39II
A* rw+ Raw alpha samples
AI rw- Adobe Illustrator CS2
ART* rw- PFS: 1st Publisher Clip Art
ARW r-- Sony Alpha Raw Image Format
AVI* r-- Microsoft Audio/Visual Interleaved
AVS* rw+ AVS X image
B* rw+ Raw blue samples
BGR* rw+ Raw blue, green, and red samples
BMP* rw- Microsoft Windows bitmap image
BMP2* -w- Microsoft Windows bitmap image v2
BMP3* -w- Microsoft Windows bitmap image v3
BRG* rw+ Raw blue, red, and green samples
C* rw+ Raw cyan samples
CAPTION* r-- Image caption
CIN* rw+ Cineon Image File
CIP* -w- Cisco IP phone image format
CLIP* -w+ Image Clip Mask
CMYK* rw+ Raw cyan, magenta, yellow, and black samples
CMYKA* rw+ Raw cyan, magenta, yellow, black, and alpha samples
CR2 r-- Canon Digital Camera Raw Image Format
CRW r-- Canon Digital Camera Raw Image Format
CUR* rw- Microsoft icon
CUT* r-- DR Halo
DCM* r-- Digital Imaging and Communications in Medicine image
DICOM is used by the medical community for images like X-rays. The
specification, "Digital Imaging and Communications in Medicine
(DICOM)", is available at http://medical.nema.org/. In particular,
see part 5 which describes the image encoding (RLE, JPEG, JPEG-LS),
and supplement 61 which adds JPEG-2000 encoding.
DCR r-- Kodak Digital Camera Raw Image File
DCX* rw+ ZSoft IBM PC multi-page Paintbrush
DDS* r-- Microsoft DirectDraw Surface
DFONT* r-- Multi-face font package (Freetype 2.2.1)
DNG r-- Digital Negative
DPX* rw- SMPTE 268M-2003 (DPX 2.0)
Digital Moving Picture Exchange Bitmap, Version 2.0.
See SMPTE 268M-2003 specification at http://www.smtpe.org
EPDF rw- Encapsulated Portable Document Format
EPI rw- Encapsulated PostScript Interchange format
EPS rw- Encapsulated PostScript
EPS2* -w- Level II Encapsulated PostScript
EPS3* -w+ Level III Encapsulated PostScript
EPSF rw- Encapsulated PostScript
EPSI rw- Encapsulated PostScript Interchange format
EPT rw- Encapsulated PostScript with TIFF preview
EPT2 rw- Encapsulated PostScript Level II with TIFF preview
EPT3 rw+ Encapsulated PostScript Level III with TIFF preview
ERF r-- Epson RAW Format
FAX* rw+ Group 3 FAX
FAX machines use non-square pixels which are 1.5 times wider than they
are tall but computer displays use square pixels, therefore FAX images
may appear to be narrow unless they are explicitly resized using a
geometry of "150x100%".
FITS* rw- Flexible Image Transport System
FRACTAL* r-- Plasma fractal image
FTS* rw- Flexible Image Transport System
G* rw+ Raw green samples
G3* rw- Group 3 FAX
GBR* rw+ Raw green, blue, and red samples
GIF* rw+ CompuServe graphics interchange format
GIF87* rw- CompuServe graphics interchange format (version 87a)
GRADIENT* r-- Gradual linear passing from one shade to another
GRAY* rw+ Raw gray samples
GRB* rw+ Raw green, red, and blue samples
GROUP4* rw- Raw CCITT Group4
HISTOGRAM* -w- Histogram of the image
HRZ* rw- Slow Scan TeleVision
HTM* -w- Hypertext Markup Language and a client-side image map
HTML* -w- Hypertext Markup Language and a client-side image map
ICB* rw+ Truevision Targa image
ICO* rw+ Microsoft icon
ICON* rw- Microsoft icon
INFO -w+ The image format and characteristics
INLINE* r-- Base64-encoded inline images
IPL* rw+ IPL Image Sequence
JNG* rw- JPEG Network Graphics
See http://www.libpng.org/pub/mng/ for details about the JNG
format.
JPEG* rw- Joint Photographic Experts Group JFIF format (62)
JPG* rw- Joint Photographic Experts Group JFIF format (62)
K* rw+ Raw black samples
K25 r-- Kodak Digital Camera Raw Image Format
KDC r-- Kodak Digital Camera Raw Image Format
LABEL* r-- Image label
M* rw+ Raw magenta samples
M2V rw+ MPEG Video Stream
M4V rw+ Raw MPEG-4 Video
MAP* rw- Colormap intensities and indices
MAT rw+ MATLAB image format
MATTE* -w+ MATTE format
MIFF* rw+ Magick Image File Format
MNG* rw+ Multiple-image Network Graphics (libpng 1.2.10)
See http://www.libpng.org/pub/mng/ for details about the MNG
format.
MONO* rw- Raw bi-level bitmap
MOV rw+ MPEG Video Stream
MP4 rw+ MPEG-4 Video Stream
MPC* rw+ Magick Persistent Cache image format
MPEG rw+ MPEG Video Stream
MPG rw+ MPEG Video Stream
MRW r-- Sony (Minolta) Raw Image File
MSL* --- Magick Scripting Language
MSVG -w+ ImageMagick's own SVG internal renderer
MTV* rw+ MTV Raytracing image format
MVG* rw- Magick Vector Graphics
NEF r-- Nikon Digital SLR Camera Raw Image File
NULL* rw- Constant image of uniform color
O* rw+ Raw opacity samples
ORF r-- Olympus Digital Camera Raw Image File
OTB* rw- On-the-air bitmap
OTF* r-- Open Type font (Freetype 2.2.1)
PAL* rw- 16bit/pixel interleaved YUV
PALM* rw+ Palm pixmap
PAM* rw+ Common 2-dimensional bitmap format
PATTERN* r-- Predefined pattern
PBM* rw+ Portable bitmap format (black and white)
PCD* rw- Photo CD
PCDS* rw- Photo CD
PCL rw+ Printer Control Language
PCT* rw- Apple Macintosh QuickDraw/PICT
PCX* rw- ZSoft IBM PC Paintbrush
PDB* rw+ Palm Database ImageViewer Format
PDF rw+ Portable Document Format
PDFA rw+ Portable Document Archive Format
PEF r-- Pentax Electronic File
PFA* r-- Postscript Type 1 font (ASCII) (Freetype 2.2.1)
PFB* r-- Postscript Type 1 font (binary) (Freetype 2.2.1)
PFM* rw+ Portable float format
PGM* rw+ Portable graymap format (gray scale)
PICON* rw- Personal Icon
PICT* rw- Apple Macintosh QuickDraw/PICT
PIX* r-- Alias/Wavefront RLE image format
PJPEG* rw- Joint Photographic Experts Group JFIF format (62)
PLASMA* r-- Plasma fractal image
PNG* rw- Portable Network Graphics (libpng 1.2.10)
See http://www.libpng.org/ for details about the PNG format.
PNG24* rw- opaque 24-bit RGB (zlib 1.2.3)
PNG32* rw- opaque or transparent 32-bit RGBA
PNG8* rw- 8-bit indexed with optional binary transparency
PNM* rw+ Portable anymap
PPM* rw+ Portable pixmap format (color)
PREVIEW* -w- Show a preview an image enhancement, effect, or f/x
PS rw+ PostScript
PS2* -w+ Level II PostScript
PS3* -w+ Level III PostScript
PSD* rw+ Adobe Photoshop bitmap
PTIF* rw+ Pyramid encoded TIFF
PWP* r-- Seattle Film Works
R* rw+ Raw red samples
RADIAL-GRADIENT* r-- Gradual radial passing from one shade to another
RAF r-- Fuji CCD-RAW Graphic File
RAS* rw+ SUN Rasterfile
RBG* rw+ Raw red, blue, and green samples
RGB* rw+ Raw red, green, and blue samples
RGBA* rw+ Raw red, green, blue, and alpha samples
RGBO* rw+ Raw red, green, blue, and opacity samples
RLA* r-- Alias/Wavefront image
RLE* r-- Utah Run length encoded image
SCR* r-- ZX-Spectrum SCREEN$
SCT* r-- Scitex HandShake
SFW* r-- Seattle Film Works
SGI* rw+ Irix RGB image
SHTML* -w- Hypertext Markup Language and a client-side image map
SR2 r-- Sony Raw Format 2
SRF r-- Sony Raw Format
STEGANO* r-- Steganographic image
SUN* rw+ SUN Rasterfile
SVG -w+ Scalable Vector Graphics
SVGZ -w+ Compressed Scalable Vector Graphics
TEXT* rw- Text
TGA* rw+ Truevision Targa image
THUMBNAIL* -w+ EXIF Profile Thumbnail
TIFF* rw+ Tagged Image File Format (LIBTIFF, Version 3.8.2)
TIFF64* --- Tagged Image File Format (64-bit) (LIBTIFF, Version 3.8.2)
TILE* r-- Tile image with a texture
TIM* r-- PSX TIM
TTC* r-- TrueType font collection (Freetype 2.2.1)
TTF* r-- TrueType font (Freetype 2.2.1)
TXT* rw- Text
UIL* -w- X-Motif UIL table
UYVY* rw- 16bit/pixel interleaved YUV
VDA* rw+ Truevision Targa image
VICAR* rw- VICAR rasterfile format
VID* rw+ Visual Image Directory
VIFF* rw+ Khoros Visualization image
VST* rw+ Truevision Targa image
WBMP* rw- Wireless Bitmap (level 0) image
WMV rw+ Windows Media Video
WPG* r-- Word Perfect Graphics
X3F r-- Sigma Camera RAW Picture File
XBM* rw- X Windows system bitmap (black and white)
XC* r-- Constant image uniform color
XCF* r-- GIMP image
XPM* rw- X Windows system pixmap (color)
XPS r-- Microsoft XML Paper Specification
XV* rw+ Khoros Visualization image
Y* rw+ Raw yellow samples
YCbCr* rw+ Raw Y, Cb, and Cr samples
YCbCrA* rw+ Raw Y, Cb, Cr, and alpha samples
YUV* rw- CCIR 601 4:1:1 or 4:2:2
* native blob support
r read support
w write support
+ support for multiple images
6,安装RMagick
[root@li96-10 ~]# gem install rmagick #出现一大堆的下面的错误
...
...
...No definition for Pixel_to_HSL
No definition for Pixel_to_hsla
No definition for Pixel_to_s
No definition for Montage_initialize
No definition for rm_no_freeze
No definition for Info_initialize
No definition for Info_channel
No definition for rm_no_freeze
No definition for Info_define
No definition for Info_aset
No definition for Info_aref
No definition for Info_undefine
No definition for PolaroidOptions_initialize
No definition for GradientFill_initialize
No definition for GradientFill_fill
No definition for TextureFill_initialize
No definition for TextureFill_fill
No definition for ImageMagickError_initialize
No definition for Enum_initialize
No definition for Enum_to_s
No definition for Enum_to_i
No definition for Enum_spaceship
No definition for Enum_case_eq
很无奈啊,除了这么多错误,应该是没有找到imagemagick库的错误,不管了,还是源代码安装吧
[root@li96-10 ~]# wget http://rubyforge.org/frs/download.php/68157/RMagick-2.13.0.tar.gz
[root@li96-10 RMagick-2.13.0]# tar zxvf RMagick-2.13.0.tar.gz
[root@li96-10 RMagick-2.13.0]# cd RMagick-2.13.0
[root@li96-10 RMagick-2.13.0]# ruby setup.rb
#有如下错误:
checking for Magick-config... no
Can't install RMagick 2.13.0. Can't find Magick-config in /usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
解决办法:centos下:yum install ImageMagick-devel ubuntu下:apt-get install libmagick9-dev
[root@li96-10 RMagick-2.13.0]# ruby setup.rb install
测试安装
[root@li96-10 ~]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):003:0> require 'RMagick'
=> true
irb(main):004:0>