简体   繁体   中英

Get thumbnail pdf with php + Imagick

<?php 
    $dir_pdf = "http://example.com/test/uploads/test_file.pdf";
    $dir_thumbnail = "http://example.com/test/uploads/test_file.jpg"
    $im = new Imagick();
    $im->readImage($dir_pdf);
    header("Content-Type: image/" . $im->getImageFormat());
    echo $im;
?>

In folder "uploads" i have a pdf file
My server installed Imagick & Ghostscript
Why this code can't run :) Thank you .

<?php
    $im = new Imagick("uploads/test_file.pdf[0]");
    $im->setImageFormat("jpg");
    $type=$im->getFormat();
    header("Content-type: $type");
    echo $im->getimageblob();
?>

this is my code :)
I put test_file.pdf in folder uploads
it work ^^!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM