Ubuntu imageMagick does not convert PDF to PNG fro

2019-09-07 03:26发布

问题:

I have a problem when I want to convert a pdf file using a simple php script like:

<?php
    shell_exec("convert pdf.pdf image.png");
?>

The conversion works fine when converting from terminal (SSH connection), but only if I'm logged in as myself. The following will give no error nor an output file 'image.png'.

sudo su www-data
<enters password>
convert pdf.pdf image.png

回答1:

Your file/folder permissions are wrong, imagemagick (convert) needs write permissions:

sudo chmod g+w folder

check out http://www.tuxfiles.org/linuxhelp/filepermissions.html for a good help/explanation what the file/folder "modes" are and how they work.