Linux环境安装imagemagick

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MrZhangXL/article/details/77934691

系统环境:

[root@njyf-test-zxl-10-20-2-127 pic]# cat /etc/*release
CentOS Linux release 7.1.1503 (Core) 

废话不多说,直接按如下步骤操作即可。

步骤1:安装一些必要的yum,直接复制如下命令即可

yum install tcl-devel.x86_64 libpng-devel.x86_64 libjpeg-devel.x86_64 ghostscript-devel.x86_64 bzip2-devel.x86_64 freetype-devel.x86_64 libtiff-devel.x86_64
yum install libjpeg-devel.x86_64 libpng-devel.x86_64 glib2-devel.x86_64 fontconfig-devel.x86_64 zlib-devel.x86_64 libwmf-devel.x86_64 freetype-devel.x86_64 libtiff-devel.x86_64

步骤2:安装zlib

https://sourceforge.net/projects/libpng/files/zlib/1.2.8/

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure

make

make install

步骤3:安装libpng

下载地址:
https://sourceforge.net/projects/libpng/files/libpng16/older-releases/1.6.21/libpng-1.6.21.tar.gz/download

tar zxvf libpng-1.4.4.tar.gz
cd libpng-1.6.21
cd scripts/
mv makefile.linux ../makefile
cd ..
make
make install

注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个

zlib只能是1.2.8版本,libpng只能是1.6.21版本,如果你下载的是其他版本有可能会出现两者不兼容,在make libpng时会抛出如下异常:
agickCore/.libs/libMagickCore-7.Q16HDRI.so: undefined reference to `jpeg_default_qtables’

步骤4:安装freetype

wget http://www.imagemagick.org/download/delegates/freetype-2.7.1.tar.gz

tar zxvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure
make
make install

步骤5:安装Jpeg

wget http://www.imagemagick.org/download/delegates/jpegsrc.v9b.tar.gz
tar zxvf pegsrc.v9b.tar.gz 
cd jpeg-9b
./configure --enable-shared 
make libdir=/usr/lib64   
make libdir=/usr/lib64 install

注意,这里configure一定要带–enable-shared参数,不然,不会生成共享库

步骤6:安装ImageMagick

wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar -xzvf ImageMagick-6.6.8-10.tar.gz  
./configure --prefix=/usr/local/imagemagick  
make  
make install  

步骤7:修改环境变量

vim /etc/profile
export PATH=$PATH:$JAVA_HOME/bin:**/usr/local/imagemagick/bin**
source /etc/profile

大功告成了,接下来用命令测试就好了。

convert test.jpg a.jpg -geometry +75+180 -composite f_over.jpg

convert -background none -fill white -pointsize 36 label:A label_A_white.png

测试是成功的。

没有更多推荐了,返回首页