php imagick无法将pdf转换为jpeg

xmq68pz9  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(387)

我在windows操作系统上安装了imagick和ghostscript。我想把pdf文件转换成图像。imagick已安装并显示在phpinfo中,但pdf不会转换为图像。
我试过用“magick”关键字代替convert。我还安装了遗留实用程序,并使用了'转换'功能都没有用。
以下是我的xampp和pc规格:
架构:x86,vc14,支持ts,win。8、gswin32

if(move_uploaded_file($_FILES['pdf']['tmp_name'], $pdfDirectory.$filename)) {

    //the path to the PDF file
    $pdfWithPath = $pdfDirectory.$filename;

    //add the desired extension to the thumbnail
    $thumb = $thumb.".jpg";

    //execute imageMagick's 'convert', setting the color space to RGB and size to 200px wide
    exec("convert \"{$pdfWithPath}[0]\" -colorspace RGB -geometry 100 $thumbDirectory$thumb");

    //show the image
    $thumbnail =  "<p><a href=\"$pdfWithPath\"><img src=\"pdfimage/$thumb\" alt=\"\" /></a></p>";
    $filename1 =  "<p><a href=\"$pdfWithPath\"> FILE </a></p>";
    //echo "$thumbnail";
    //echo "$filename";
    }
    $query = "INSERT INTO files (thumb, department,  title, author, publisher, date_published,  isbn) VALUES ('$thumbnail' , '$dept',  '$filename', '$author', '$publisher', '$datepublished',  '$isbn')";
    $run = mysqli_query($conn, $query);`
qvk1mo1f

qvk1mo1f1#

将imagick路径添加到用户变量,或在安装imagick时选择add path to environment variables

相关问题