即使安装了Imagic软件包和ghostscript,Imagick也无法正常工作

时间:2015-09-23 15:32:42

标签: php window imagick

我想创建PDF文件第一页的图像。因此,我遵循了此链接的说明 - Install Imagick for PHP and Apache on Windows

我已成功完成的所有步骤如上所示链接。然后我写了我的PHP代码,如下 -

<?php 

   try{

     $im = new Imagick();
     $im->setResolution(300,300);
     $im->readImage('mypdf.pdf[0]');
     $im->scaleImage(1000,0);
     $im->setImageFormat('jpg');
    //$im->setImageCompression(imagick::COMPRESSION_JPG); 
     $im->setCompressionQuality(100);
     $im = $im->flattenImages();
    $im->writeImage('test.jpg');
  }

  catch(Exception $e) {
     echo 'Message: ' .$e->getMessage();
   }
?> 

我收到了以下错误 -

Message: PDFDelegateFailed `[ghostscript library 9.16] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" -dFirstPage=1 -dLastPage=1 "-sOutputFile=C:/Windows/TEMP/magick-4220l9dSVismOfxn%d" "-fC:/Windows/TEMP/magick-4220xKPtbptSyL7t" "-fC:/Windows/TEMP/magick-4220niNseKCMcRtD"': Error: /undefinedfilename in (C:/Windows/TEMP/magick-4220xKPtbptSyL7t) Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push Dictionary stack: --dict:1200/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)-- Current allocation mode is local Last OS error: No such file or directory GPL Ghostscript 9.16: Unrecoverable error, exit code 1 @ error/pdf.c/InvokePDFDelegate/271

现在我无法理解那里出了什么问题。它是如何修复的,所以我陷入了这个阶段。所以,任何人都可以帮我找到这个问题。

UPDATE - 我搜索了这个问题,发现一个链接 - Why converting this PDF file fails when using ImageMagick/Ghostscript?

但我无法理解它的答案。我不确定读完后该怎么做。

提前致谢。

0 个答案:

没有答案