0

I'm having a hard time converting a pdf file to jpg using the php Imagick Library on a wordpress based web site.

I have done some reading and I think I need to install Ghostscript to achieve my goal. Is that the case or I can do it without Ghostscript.

My code looks like that:

$img = new Imagick();
$img->setResolution(200,350);
$img->readImageFile($link.'[0]');
$img->setImageFormat('jpeg');
$img->destroy();
$img->clear();

I can successfully run the above code without the setImageFormat. setImageFormat produces an error. All other commands run successfully though.

Any ideas??

Thanks

ion
  • 1,033
  • 2
  • 16
  • 46

1 Answers1

0

You'll need to install GhostScript. PDF is handled by the GhostScript interpreter.

David van Driessche
  • 6,602
  • 2
  • 28
  • 41
  • Thanks I'm already doing so. I will vote your answer once everything works. – ion Feb 04 '13 at 13:12
  • Apparently the hosting provider cannot install Ghostscript for security reasons since it uses shell_exec() and exec() and since it is on a shared hosting plan and safe_mode is on. So I guess I'm looking for an alternative solution. Any help?? – ion Feb 05 '13 at 10:27
  • Not very helpful I know but I suggest changing hosts. – Bonzo Feb 05 '13 at 18:22
  • I mainly know commercial alternatives, but even there being able to use exec or shell_exec is a necessity I'm afraid... – David van Driessche Feb 05 '13 at 23:27