生產安裝 image轉換以及pdf轉換字體格式[ubuntu centos系統 ]

使用yum直接安裝報錯: html

[Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7" linux

解決: ubuntu

vi /etc/yum.repos.d/epel.repo vim

gpgcheck=0 windows

安裝圖片魔法化工具imagemagick centos

centos 安裝 服務器

yum install libjpeg* 網絡

yum install libpng* dom

yum install freetype* curl

yum install gd*

yum install ImageMagick ImageMagick-devel

yum install ImageMagick ImageMagick-develgd*freetype*libpng*libjpeg* -y

convert -version

測試: 輸入convert -resize 100x100 src.jpg des.jpg 執行成功,代表安裝成功

項目程序報錯: egrep "StandardErro" production.log

StandardError (Error while running convert: convert: not authorized `UZGCD' @ error/constitute.c/ReadImage/454.

StandardError (Error while running convert: convert: not authorized `UZGCD' @ error/constitute.c/ReadImage/454.

配置文件:

cp /etc/ImageMagick/policy.xml{,.bak}

vim /etc/ImageMagick/policy.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE policymap [

<!ELEMENT policymap (policy)+>

<!ELEMENT policy (#PCDATA)>

<!ATTLIST policy domain (delegate|coder|filter|path|resource) #IMPLIED>

<!ATTLIST policy name CDATA #IMPLIED>

<!ATTLIST policy rights CDATA #IMPLIED>

<!ATTLIST policy pattern CDATA #IMPLIED>

<!ATTLIST policy value CDATA #IMPLIED>

]>

<policymap>

<!-- <policy domain="system" name="precision" value="6"/> -->

<!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->

<!-- <policy domain="resource" name="memory" value="2GiB"/> -->

<!-- <policy domain="resource" name="map" value="4GiB"/> -->

<!-- <policy domain="resource" name="area" value="1GB"/> -->

<!-- <policy domain="resource" name="disk" value="16EB"/> -->

<!-- <policy domain="resource" name="file" value="768"/> -->

<!-- <policy domain="resource" name="thread" value="4"/> -->

<!-- <policy domain="resource" name="throttle" value="0"/> -->

<!-- <policy domain="resource" name="time" value="3600"/> -->

<policy domain="coder" rights="none" pattern="EPHEMERAL" />

<policy domain="coder" rights="none" pattern="URL" />

<policy domain="coder" rights="none" pattern="HTTPS" />

<policy domain="coder" rights="none" pattern="MVG" />

<policy domain="coder" rights="none" pattern="MSL" />

<policy domain="coder" rights="none" pattern="TEXT" />

<policy domain="coder" rights="none" pattern="SHOW" />

<policy domain="coder" rights="none" pattern="WIN" />

<policy domain="coder" rights="none" pattern="PLT" />

<policy domain="path" rights="none" pattern="@*" />

</policymap>

# 備註 綠色字體是源文件配置的規則,紅色字體是後續添加的格式規則

ubuntu安裝 apt-get install imagemagick

安裝網頁轉換爲pdf -----wkhtmltopdf

ubuntu安裝

sudo apt-get install xvfb

wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-i386.deb

sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-i386.deb

echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$@"'| sudo tee /usr/local/bin/wkhtmltopdf.sh >/dev/null

sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh

若是能夠生成還須要字體格式設置

1)先網絡下載或者直接在windows系統中找到宋體和雅黑字體

2)mkdir /usr/share/fonts/msfonts

將字體文件目錄下的字體 上傳到以上目錄中

sudo mkfontdir;sudo mkfontscale;sudo fc-cache

驗證 # 驗證:【隨便目錄下:】

安裝好後 wkhtmltopdf http://baidu.com baidu.pdf

centos 安裝

下載頁面: https://wkhtmltopdf.org/downloads.html

yum -y install libXrender* libXext* libfontconfig*

若是報錯: 安裝對應的庫包

上傳好的下載包到服務器

tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

sudo cp wkhtmltox/bin/wkhtmltopdf /usr/bin/

wkhtmltopdf http://baidu.com baidu.pdf

若是能夠生成還須要字體格式設置

1)先網絡下載或者直接在windows系統中找到宋體和雅黑字體

2)mkdir /usr/share/fonts/msfonts

將字體文件目錄下的字體 上傳到以上目錄中

sudo mkfontdir;sudo mkfontscale;sudo fc-cache

驗證 # 驗證:【隨便目錄下:】

安裝好後 wkhtmltopdf http://baidu.com baidu.pdf

相關文章
相關標籤/搜索