centos使用Ghostscript进行pdf转图片


从yum安装GhostScript(不建议)

yum install -y ghostscript

执行命令

gs -dSAFER -dBATCH -dNOPAUSE -r250 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=jpeg -sOutputFile=toImg.jpg toImg.pdf

通过源码安装(建议)

Linux 编译安装 ghostscript 最新版

https://github.com/ArtifexSoftware/ghostpdl-downloads/releases

进入Linux终端

wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs925/ghostscript-9.25.tar.gz
tar zxvf ghostscript-9.25.tar.gz
cd ghostscript-9.25
./configure --prefix=/usr
make all
make install

开始配置

sudo vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
source /etc/profile
echo $PKG_CONFIG_PATH

上述配置结束后转向这个安装

https://www.cnblogs.com/vaen/p/14851766.html

配置 PKG_CONFIG_PATH

验证

pkg-config --cflags --libs MagickWand
// 出现下列信息才表示配置成功
-fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/local/include/ImageMagick-7  -L/usr/local/lib -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI  

遇到错误

error while loading shared libraries: libMagickWand-7.Q16HDRI.so.9: cannot open shared object file: No such file or directory

解决参考

https://blog.csdn.net/hankerbit/article/details/83834349

sudo vim /etc/ld.so.conf
// 在"include ld.so.conf.d/*.conf"下方增加"/usr/local/lib"
sudo /sbin/ldconfig -v


备注

相关地址
https://download.imagemagick.org/ImageMagick/download/binaries/
https://github.com/gographics/imagick
https://www.ghostscript.com/download/gsdnld.html

centos环境如何安装:
https://imagemagick.org/script/download.php

错误:
ERROR_MISSING_DELEGATE: no decode delegate for this image format `' @ error/constitute.c/ReadImage/572

https://download.imagemagick.org/ImageMagick/download/linux/CentOS/x86_64/ImageMagick-7.0.11-14.x86_64.rpm
https://download.imagemagick.org/ImageMagick/download/linux/CentOS/x86_64/ImageMagick-libs-7.0.11-14.x86_64.rpm

sudo rpm -Uvh ImageMagick-7.0.11-14.x86_64.rpm --nodeps --force
sudo rpm -Uvh ImageMagick-libs-7.0.11-14.x86_64.rpm --nodeps --force


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM