Ubuntu系统一般自带ImageMagick,我们使用其中的convert做图片的格式转换,但是新安装的Ubuntu系统一般会将convert命令的权限默认设置成“none”,具体信息在/etc/ImageMagick-6/policy.xml 中
初始状态的权限如下:
<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
我们看到rights后面的权限都是“none”,所以我们需要将其改为"read|write",
<!-- disable ghostscript format types -->
<policy domain="coder" rights="read|write" pattern="PS" />
<policy domain="coder" rights="read|write" pattern="EPS" />
<policy domain="coder" rights="read|write" pattern="PDF" />
<policy domain="coder" rights="read|write" pattern="XPS" />
我们注意到这里的格式转换只有pdf格式,我们要讲eps转换为tif,png,或者jpg的话需要自己在这个.xml文件中添加对应的格式
<!-- disable ghostscript format types -->
<policy domain="coder" rights="read|write" pattern="PS" />
<policy domain="coder" rights="read|write" pattern="EPS" />
<policy domain="coder" rights="read|write" pattern="PDF" />
<policy domain="coder" rights="read|write" pattern="TIF" />
<policy domain="coder" rights="read|write" pattern="JPG" />
<policy domain="coder" rights="read|write" pattern="PNG" />
<policy domain="coder" rights="read|write" pattern="XPS" />