1. 下载GraphicsMagick,官方FTP下载地址:ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.gz
LATEST是最新版本的意思,所以当前我现在最新的版本是1.3.28。
2. 下载完成后解压压缩包
tar -zxvf GraphicsMagick-LATEST.tar.gz
3. 进入解压目录(解压后目录名称跟版本有关,根据实际目录进入)
cd GraphicsMagick-1.3.28
4. 安装扩展
yum install gcc gcc-c++ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libwebp-devel libwebp
5. 编译GraphicsMagick
./configure --prefix=/opt/GraphicsMagick
查看返回结果,确保我下面标记红色的栏目是yes的
Option Configure option Configured value
-----------------------------------------------------------------
Shared libraries --enable-shared=no no
Static libraries --enable-static=yes yes
GNU ld --with-gnu-ld=yes yes
Quantum depth --with-quantum-depth=8 8
Modules --with-modules=no no
Delegate Configuration:
BZLIB --with-bzlib=yes no
DPS --with-dps=yes no
FlashPIX --with-fpx=no no
FreeType 2.0 --with-ttf=yes yes
Ghostscript None gs (unknown)
Ghostscript fonts --with-gs-font-dir=default none
Ghostscript lib --with-gslib=no no
JBIG --with-jbig=yes no
JPEG v1 --with-jpeg=yes yes
JPEG-2000 --with-jp2=yes no
LCMS v2 --with-lcms2=yes no
LZMA --with-lzma=yes no
Magick++ --with-magick-plus-plus=yes no (failed tests)
PERL --with-perl=no no
PNG --with-png=yes yes (-lpng15)
TIFF --with-tiff=yes no
TRIO --with-trio=yes no
WEBP --with-webp=yes yes
Windows fonts --with-windows-font-dir= none
6. 安装
make && make install
7. 安装完成,测试执行
/opt/GraphicsMagick/bin/gm version
8.测试GraphicsMagick,在/opt/目录下放置一张1.jpg的图片
/opt/GraphicsMagick/bin/gm convert /opt/1.jpg /opt/1.webp