本文介绍了致命错误:无法在imagick中创建临时文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have some pdfs in a folder called downloads and i want to generate thumbnails in jpg format using imagick in php but i am getting error as unable to create temporary file. error i am getting is this:







Fatal error: Uncaught exception 'ImagickException' with message 'unable to create temporary file `/home/vrwebqbj/public_html/virtuereal.com/KyoritsuElectric/admin/images/downloads/demoPDF.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/397' in /home/vrwebqbj/public_html/virtuereal.com/KyoritsuElectric/admin/imagickTest2.php:14 Stack trace: #0 /home/vrwebqbj/public_html/virtuereal.com/KyoritsuElectric/admin/imagickTest2.php(14): Imagick->__construct('/home/vrwebqbj/...') #1 {main} thrown in /home/vrwebqbj/public_html/virtuereal.com/KyoritsuElectric/admin/imagickTest2.php on line 14





到目前为止我试过了:





This is so far I tried :

<?php
error_reporting(1);
$source       = __DIR__."/images/downloads/demoPDF.pdf"; //Source PDF File
$target     = "myfile.jpg"; // Output File



/*function genPdfThumbnail($source, $target)
    {*/
        //$source = realpath($source);
        $target = dirname($source).DIRECTORY_SEPARATOR.$target;
        //echo $target;
        //echo __DIR__;
        $im     = new Imagick($source."[0]"); // 0-first page, 1-second page
        $im->setImageColorspace(255); // prevent image colors from inverting
        $im->setimageformat("jpeg");
        $im->thumbnailimage(160, 120); // width and height
        $im->writeimage($target);
        $im->clear();
        $im->destroy();
   // }
    //genPdfThumbnail('images/downloads/demoPDF.pdf','myfile.jpg');
?>
<img src="KyoritsuElectric/admin/images/downloads/myfile.jpg" />

推荐答案




这篇关于致命错误:无法在imagick中创建临时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:32