【CentOS7】安装GraphicsMagick
【CentOS7】安装GraphicsMagick
工具,没有时安装
yum install -y autoconf bc vim wget screen telnet lrzsz zip unzip lsof locate nc tcpdump strace iftop iotop htop crontabs strace ntpdate curl
编译器,没有则安装
yum -y install gcc gcc-c++
图片和字体支持插件,freetype字体
yum -y install libjpeg libjpeg-devel libpng libpng-devel giflib giflib-devel libwebp libwebp-devel freetype freetype-devel libtool-ltdl libtool-ltdl-devel
下载解压GraphicsMagick
cd /ycx
wget https://util.obs.cn-east-3.myhuaweicloud.com/GraphicsMagick-1.3.35.tar.gz
tar -zxvf GraphicsMagick-1.3.35.tar.gz
mv GraphicsMagick-1.3.35 GraphicsMagick
cd /ycx/GraphicsMagick
安装,如果configure提示configure: error: libltdl is required for modules build, 则 yum install libtool-ltdl libtool-ltdl-devel
./configure --prefix=/ycx/GraphicsMagick --with-quantum-depth=8 --enable-shared --enable-static --enable-lzw --without-perl --with-modules
make && make install
编辑
vim /etc/ld.so.conf
# 追加
/ycx/GraphicsMagick/lib/
# 生效
ldconfig
设置环境变量
全局
vim /etc/profile
# 追加
export GMAGICK_HOME="/ycx/GraphicsMagick"
export PATH="$GMAGICK_HOME/bin:$PATH"
LD_LIBRARY_PATH=$GMAGICK_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
生效配置
source /etc/profile
用户
vim /root/.bash_profile
# 追加
export GMAGICK_HOME="/ycx/GraphicsMagick"
export PATH="$GMAGICK_HOME/bin:$PATH"
LD_LIBRARY_PATH=$GMAGICK_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
生效配置
source /root/.bash_profile
测试
gm -version
gm convert -list formats
将gm考到/usr/bin目录下
cp /ycx/GraphicsMagick/bin/gm /usr/bin/
./configure --help 查看参数
安装位置相关参数:
--prefix=PATH:指定安装目录的前缀,即安装目录的根路径。
--bindir=PATH:指定可执行文件的安装目录。
--libdir=PATH:指定库文件的安装目录。
--datadir=PATH:指定数据文件的安装目录。
编译选项:
--enable-shared:启用动态链接库(DLL或.so文件)的编译。
--enable-static:启用静态链接库的编译。
--disable-static:禁用静态链接库的编译。
--with-modules:启用模块支持。
--with-quantum-depth=8 或 --with-quantum-depth=16:设置图像处理的量子深度,8位或16位。量子深度影响图像处理的精度和性能。
禁用特定功能:
--disable-openmp:禁用OpenMP支持,即禁用多线程处理。这可能会减少GraphicsMagick处理图像时的性能,但在某些情况下可以提高稳定性或兼容性。
--without-perl、--without-magick-plus-plus等:禁用对特定语言或库的绑定或支持。
其他选项:
--enable-libtool-verbose:启用libtool的详细输出,有助于调试编译问题。
--with-included-ltdl:使用内置的libltdl库,而不是系统上的版本。

浙公网安备 33010602011771号